Add high resolution WallTimer to SampleApp
Gives better than 1 ms results when timing framerate.
Review URL: https://codereview.chromium.org/1288473002
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 486feed..5bb223a 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1313,8 +1313,9 @@
}
// Do this after presentGL and other finishing, rather than in afterChild
- if (fMeasureFPS && fMeasureFPS_StartTime) {
- fMeasureFPS_Time += SkTime::GetMSecs() - fMeasureFPS_StartTime;
+ if (fMeasureFPS) {
+ fTimer.end();
+ fMeasureFPS_Time += fTimer.fWall;
}
}
@@ -1351,9 +1352,8 @@
}
if (fMeasureFPS) {
- if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) {
- fMeasureFPS_StartTime = SkTime::GetMSecs();
- }
+ (void)SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT);
+ fTimer.start();
} else {
(void)SampleView::SetRepeatDraw(child, 1);
}
@@ -1935,7 +1935,7 @@
}
if (fMeasureFPS) {
- title.appendf(" %8.3f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT);
+ title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT);
}
SkView* view = curr_view(this);