Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
4e766280
There was an error fetching the commit references. Please try again later.
Commit
4e766280
authored
3 years ago
by
Morph
Browse files
Options
Downloads
Patches
Plain Diff
common: wall_clock: Utilize constants for ms, us, and ns ratios
parent
11099dda
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/wall_clock.cpp
+2
-2
2 additions, 2 deletions
src/common/wall_clock.cpp
src/common/wall_clock.h
+4
-0
4 additions, 0 deletions
src/common/wall_clock.h
src/common/x64/native_clock.cpp
+3
-3
3 additions, 3 deletions
src/common/x64/native_clock.cpp
with
9 additions
and
5 deletions
src/common/wall_clock.cpp
+
2
−
2
View file @
4e766280
...
@@ -73,8 +73,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
...
@@ -73,8 +73,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
rtsc_frequency
=
EstimateRDTSCFrequency
();
rtsc_frequency
=
EstimateRDTSCFrequency
();
}
}
// Fallback to StandardWallClock if
rtsc period is higher than a
nano
second
// Fallback to StandardWallClock if
the hardware TSC does not have
nanosecond
precision.
if
(
rtsc_frequency
<=
1000000000
)
{
if
(
rtsc_frequency
<=
WallClock
::
NS_RATIO
)
{
return
std
::
make_unique
<
StandardWallClock
>
(
emulated_cpu_frequency
,
return
std
::
make_unique
<
StandardWallClock
>
(
emulated_cpu_frequency
,
emulated_clock_frequency
);
emulated_clock_frequency
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
src/common/wall_clock.h
+
4
−
0
View file @
4e766280
...
@@ -13,6 +13,10 @@ namespace Common {
...
@@ -13,6 +13,10 @@ namespace Common {
class
WallClock
{
class
WallClock
{
public:
public:
static
constexpr
u64
NS_RATIO
=
1'000'000'000
;
static
constexpr
u64
US_RATIO
=
1'000'000
;
static
constexpr
u64
MS_RATIO
=
1'000
;
virtual
~
WallClock
()
=
default
;
virtual
~
WallClock
()
=
default
;
/// Returns current wall time in nanoseconds
/// Returns current wall time in nanoseconds
...
...
This diff is collapsed.
Click to expand it.
src/common/x64/native_clock.cpp
+
3
−
3
View file @
4e766280
...
@@ -47,9 +47,9 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen
...
@@ -47,9 +47,9 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen
_mm_mfence
();
_mm_mfence
();
time_point
.
inner
.
last_measure
=
__rdtsc
();
time_point
.
inner
.
last_measure
=
__rdtsc
();
time_point
.
inner
.
accumulated_ticks
=
0U
;
time_point
.
inner
.
accumulated_ticks
=
0U
;
ns_rtsc_factor
=
GetFixedPoint64Factor
(
1000000000
,
rtsc_frequency
);
ns_rtsc_factor
=
GetFixedPoint64Factor
(
NS_RATIO
,
rtsc_frequency
);
us_rtsc_factor
=
GetFixedPoint64Factor
(
1000000
,
rtsc_frequency
);
us_rtsc_factor
=
GetFixedPoint64Factor
(
US_RATIO
,
rtsc_frequency
);
ms_rtsc_factor
=
GetFixedPoint64Factor
(
1000
,
rtsc_frequency
);
ms_rtsc_factor
=
GetFixedPoint64Factor
(
MS_RATIO
,
rtsc_frequency
);
clock_rtsc_factor
=
GetFixedPoint64Factor
(
emulated_clock_frequency
,
rtsc_frequency
);
clock_rtsc_factor
=
GetFixedPoint64Factor
(
emulated_clock_frequency
,
rtsc_frequency
);
cpu_rtsc_factor
=
GetFixedPoint64Factor
(
emulated_cpu_frequency
,
rtsc_frequency
);
cpu_rtsc_factor
=
GetFixedPoint64Factor
(
emulated_cpu_frequency
,
rtsc_frequency
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment