diff options
author | mtklein <mtklein@chromium.org> | 2014-07-09 08:46:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-09 08:46:50 -0700 |
commit | 40b32be3718f0f2e01c4a21bb0004b7f93670c42 (patch) | |
tree | 6b8b8634f224b9ecf7b72b7dc47cf3594bb4bf6b /tools/Stats.h | |
parent | 79fd2161448be2e6733281ef9ccb8d89c0c169a2 (diff) |
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
Diffstat (limited to 'tools/Stats.h')
-rw-r--r-- | tools/Stats.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/Stats.h b/tools/Stats.h index 2370084fd6..5128897d85 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 @@ struct Stats { 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 |