nanobench: add median and --cpu/--gpu
BUG=skia:
R=krajcevski@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/377283002
diff --git a/tools/Stats.h b/tools/Stats.h
index 2370084..5128897 100644
--- a/tools/Stats.h
+++ b/tools/Stats.h
@@ -1,6 +1,8 @@
#ifndef Stats_DEFINED
#define Stats_DEFINED
+#include "SkTSort.h"
+
struct Stats {
Stats(const double samples[], int n) {
min = samples[0];
@@ -21,12 +23,18 @@
err += (samples[i] - mean) * (samples[i] - mean);
}
var = err / (n-1);
+
+ SkAutoTMalloc<double> sorted(n);
+ memcpy(sorted.get(), samples, n * sizeof(double));
+ SkTQSort(sorted.get(), sorted.get() + n - 1);
+ median = sorted[n/2];
}
double min;
double max;
double mean; // Estimate of population mean.
double var; // Estimate of population variance.
+ double median;
};
#endif//Stats_DEFINED