aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-06-16 14:04:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-16 14:04:34 -0700
commit90c471e73fb0bd09aef8ad1e3f0842e5d46fb342 (patch)
tree09796391108d88282b20bb931f7337cea90640aa /bench
parentad2ab61b4eec0ae43f213af3f18ffe373fe8c4aa (diff)
Refine bench_record and bench_playback:
- use high-precision wall timer only - warm caches once before measuring - measure independent samples, calculating statistics - add --verbose to control how much data we output Also removed some unloved features from bench_record. BUG=skia: R=jcgregorio@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/338203002
Diffstat (limited to 'bench')
-rw-r--r--bench/BenchTimer.cpp16
-rw-r--r--bench/BenchTimer.h23
2 files changed, 36 insertions, 3 deletions
diff --git a/bench/BenchTimer.cpp b/bench/BenchTimer.cpp
index 3617f9de58..f3e8e3b0ec 100644
--- a/bench/BenchTimer.cpp
+++ b/bench/BenchTimer.cpp
@@ -76,3 +76,19 @@ void BenchTimer::truncatedEnd() {
fTruncatedCpu = fTruncatedSysTimer->endCpu() * fDurationScale;
fTruncatedWall = fTruncatedSysTimer->endWall() * fDurationScale;
}
+
+WallTimer::WallTimer() : fWall(-1.0), fSysTimer(new BenchSysTimer) {}
+
+WallTimer::~WallTimer() {
+ delete fSysTimer;
+}
+
+void WallTimer::start(double durationScale) {
+ fDurationScale = durationScale;
+ fSysTimer->startWall();
+}
+
+void WallTimer::end() {
+ fWall = fSysTimer->endWall() * fDurationScale;
+}
+
diff --git a/bench/BenchTimer.h b/bench/BenchTimer.h
index 09950a734b..2abf10b80f 100644
--- a/bench/BenchTimer.h
+++ b/bench/BenchTimer.h
@@ -39,12 +39,29 @@ public:
double fGpu;
private:
- BenchSysTimer *fSysTimer;
- BenchSysTimer *fTruncatedSysTimer;
+ BenchSysTimer* fSysTimer;
+ BenchSysTimer* fTruncatedSysTimer;
#if SK_SUPPORT_GPU
- BenchGpuTimer *fGpuTimer;
+ BenchGpuTimer* fGpuTimer;
#endif
double fDurationScale; // for this start/end session
};
+// Same as BenchTimer above, supporting only fWall but with much lower overhead.
+// (Typically, ~30ns instead of BenchTimer's ~1us.)
+class WallTimer {
+public:
+ WallTimer();
+ ~WallTimer();
+
+ void start(double durationScale = 1);
+ void end();
+
+ double fWall;
+
+private:
+ BenchSysTimer* fSysTimer;
+ double fDurationScale;
+};
+
#endif