From a189ccdb4d5efdbbfa34a26c08656634b615f930 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 14 Jul 2014 12:28:47 -0700 Subject: nanobench: add --runOnce. BUG=skia: R=egdaniel@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/392583005 --- tools/Stats.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/Stats.h') 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); -- cgit v1.2.3