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

Unified Diff: tools/timer/SysTimer_windows.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_windows.cpp
diff --git a/tools/timer/SysTimer_windows.cpp b/tools/timer/SysTimer_windows.cpp
index 8e45b4a68ed3ccabab401ec27f6138e490e56d22..8f53a44d7c103a7c755ecd56ca2e48010ec65d7d 100644
--- a/tools/timer/SysTimer_windows.cpp
+++ b/tools/timer/SysTimer_windows.cpp
@@ -38,16 +38,24 @@ double SysTimer::endCpu() {
// at the CPU's maximum rate, even while power management clocks the CPU up and down.
// That's great, because it makes measuring wall time super simple.
+static double ticks_to_ms(unsigned _int64 ticks) {
+ // This seems to, weirdly, give the CPU frequency in kHz. That's exactly what we want!
+ LARGE_INTEGER freq_khz;
+ QueryPerformanceFrequency(&freq_khz);
+
+ return static_cast<double>(ticks) / static_cast<double>(freq_khz.QuadPart);
+}
+
void SysTimer::startWall() {
fStartWall = __rdtsc();
}
double SysTimer::endWall() {
unsigned __int64 end = __rdtsc();
+ return ticks_to_ms(end - fStartWall);
+}
- // This seems to, weirdly, give the CPU frequency in kHz. That's exactly what we want!
- LARGE_INTEGER freq_khz;
- QueryPerformanceFrequency(&freq_khz);
-
- return static_cast<double>(end - fStartWall) / static_cast<double>(freq_khz.QuadPart);
+double GetTimeMs() {
+ static const unsigned __int64 launchTime = __rdtsc();
+ return ticks_to_ms(__rdtsc() - launchTime);
}
« bench/nanobench.cpp ('K') | « tools/timer/SysTimer_posix.cpp ('k') | tools/timer/Timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698