aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/Stats.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-07-14 12:28:47 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-14 12:28:48 -0700
commita189ccdb4d5efdbbfa34a26c08656634b615f930 (patch)
treeacb2e0d38dcb8020a081c063efc8757544250c9a /tools/Stats.h
parent630598cbb87edda47aa26bc7b7f93865b34cd8de (diff)
nanobench: add --runOnce.
BUG=skia: R=egdaniel@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/392583005
Diffstat (limited to 'tools/Stats.h')
-rw-r--r--tools/Stats.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/Stats.h b/tools/Stats.h
index 67bd45d863..3f19af27cc 100644
--- a/tools/Stats.h
+++ b/tools/Stats.h
@@ -34,9 +34,15 @@ struct Stats {
SkTQSort(sorted.get(), sorted.get() + n - 1);
median = sorted[n/2];
+ // Normalize samples to [min, max] in as many quanta as we have distinct bars to print.
for (int i = 0; i < n; i++) {
+ if (min == max) {
+ // All samples are the same value. Don't divide by zero.
+ plot.append(kBars[0]);
+ continue;
+ }
+
double s = samples[i];
- // Normalize samples to [min, max] in as many quanta as we have distinct bars to print.
s -= min;
s /= (max - min);
s *= (SK_ARRAY_COUNT(kBars) - 1);