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

Unified Diff: tools/timer/SysTimer_posix.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_posix.cpp
diff --git a/tools/timer/SysTimer_posix.cpp b/tools/timer/SysTimer_posix.cpp
index 4b7d708aab0c4a7e899da8c55ddb409f43845a16..1f05ca9c38aee47899f96b3c16e19aa8e6ccf1d8 100644
--- a/tools/timer/SysTimer_posix.cpp
+++ b/tools/timer/SysTimer_posix.cpp
@@ -49,3 +49,21 @@ double SysTimer::endWall() {
}
return interval_in_ms(fWall, end_wall);
}
+
+static timespec init_launch_time() {
+ timespec launchTime;
+ if (-1 == clock_gettime(CLOCK_MONOTONIC, &launchTime)) {
+ timespec none = {0, 0};
+ return none;
+ }
+ return launchTime;
+};
+
+double GetTimeMs() {
+ static const timespec launchTime = init_launch_time();
+ timespec now;
+ if (-1 == clock_gettime(CLOCK_MONOTONIC, &now)) {
+ return 0;
+ }
+ return interval_in_ms(launchTime, now);
+}

Powered by Google App Engine
This is Rietveld 408576698