Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: tools/timer/SysTimer_mach.cpp

Issue 1204153002: Add samplingTime mode to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_loopSKP
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/timer/SysTimer_mach.cpp
diff --git a/tools/timer/SysTimer_mach.cpp b/tools/timer/SysTimer_mach.cpp
index aca12dee5203afb2109aa47d6d7b8a23c183e129..9716988a04284d75f89fc51dd56dc63858fe9d56 100644
--- a/tools/timer/SysTimer_mach.cpp
+++ b/tools/timer/SysTimer_mach.cpp
@@ -39,6 +39,16 @@ static double interval_in_ms(time_value_t start_clock, time_value_t end_clock) {
return duration_clock;
}
+static double wall_interval_in_ms(uint64_t elapsed) {
+ mach_timebase_info_data_t sTimebaseInfo;
+ if (KERN_SUCCESS != mach_timebase_info(&sTimebaseInfo)) {
+ return 0;
+ } else {
+ uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
+ return elapsedNano / 1000000.0;
+ }
+}
+
void SysTimer::startWall() {
fStartWall = mach_absolute_time();
}
@@ -54,13 +64,10 @@ double SysTimer::endCpu() {
double SysTimer::endWall() {
uint64_t end_wall = mach_absolute_time();
+ return wall_interval_in_ms(end_wall - fStartWall);
+}
- uint64_t elapsed = end_wall - fStartWall;
- mach_timebase_info_data_t sTimebaseInfo;
- if (KERN_SUCCESS != mach_timebase_info(&sTimebaseInfo)) {
- return 0;
- } else {
- uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
- return elapsedNano / 1000000.0;
- }
+double GetTimeMs() {
+ static const uint64_t launchTime = mach_absolute_time();
+ return wall_interval_in_ms(mach_absolute_time() - launchTime);
}
« bench/nanobench.cpp ('K') | « tools/Stats.h ('k') | tools/timer/SysTimer_posix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698