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

Unified Diff: tools/Stats.h

Issue 338203002: Refine bench_record and bench_playback: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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/Stats.h
diff --git a/tools/Stats.h b/tools/Stats.h
new file mode 100644
index 0000000000000000000000000000000000000000..2370084fd65506200043a70e9081ceff07002115
--- /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
« no previous file with comments | « bench/BenchTimer.cpp ('k') | tools/bench_playback.cpp » ('j') | tools/bench_playback.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698