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);
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 97854fc..c0f845d 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -16,6 +16,7 @@
#include "SkTDArray.h"
#include "SkTouchGesture.h"
#include "SkWindow.h"
+#include "timer/Timer.h"
class GrContext;
class GrRenderTarget;
@@ -183,8 +184,8 @@
bool fPerspAnim;
bool fRequestGrabImage;
bool fMeasureFPS;
- SkMSec fMeasureFPS_Time;
- SkMSec fMeasureFPS_StartTime;
+ WallTimer fTimer;
+ double fMeasureFPS_Time;
bool fMagnify;
int fTilingMode;