aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/Stats.h
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 /tools/Stats.h
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 'tools/Stats.h')
-rw-r--r--tools/Stats.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/Stats.h b/tools/Stats.h
new file mode 100644
index 0000000000..2370084fd6
--- /dev/null
+++ b/tools/Stats.h
@@ -0,0 +1,32 @@
+#ifndef Stats_DEFINED
+#define Stats_DEFINED
+
+struct Stats {
+ Stats(const double samples[], int n) {
+ min = samples[0];
+ max = samples[0];
+ for (int i = 0; i < n; i++) {
+ if (samples[i] < min) { min = samples[i]; }
+ if (samples[i] > max) { max = samples[i]; }
+ }
+
+ double sum = 0.0;
+ for (int i = 0 ; i < n; i++) {
+ sum += samples[i];
+ }
+ mean = sum / n;
+
+ double err = 0.0;
+ for (int i = 0 ; i < n; i++) {
+ err += (samples[i] - mean) * (samples[i] - mean);
+ }
+ var = err / (n-1);
+ }
+
+ double min;
+ double max;
+ double mean; // Estimate of population mean.
+ double var; // Estimate of population variance.
+};
+
+#endif//Stats_DEFINED