From: mtklein Date: Mon, 4 Aug 2014 20:57:39 +0000 (-0700) Subject: Fix calibration loop failure condition. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~6497 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2069e220034f09aad2f68b262f395e7c25b3d178;p=platform%2Fupstream%2FlibSkiaSharp.git Fix calibration loop failure condition. With the old logic, if the last attempt succeeded, we'd say we failed. We also print two lines for loop calibration failures. Quiet that down. BUG=skia: R=djsollen@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/431503004 --- diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 811fc7f..2dfd33f 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -107,16 +107,16 @@ static int clamp_loops(int loops) { static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, double* samples) { // First figure out approximately how many loops of bench it takes to make overhead negligible. - double bench_plus_overhead; + double bench_plus_overhead = 0.0; int round = 0; - do { - bench_plus_overhead = time(1, bench, canvas, NULL); - if (++round == FLAGS_maxCalibrationAttempts) { + while (bench_plus_overhead < overhead) { + if (round++ == FLAGS_maxCalibrationAttempts) { SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n", bench->getName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead)); return 0; } - } while (bench_plus_overhead < overhead); + bench_plus_overhead = time(1, bench, canvas, NULL); + } // Later we'll just start and stop the timer once but loop N times. // We'll pick N to make timer overhead negligible: @@ -547,8 +547,7 @@ int nanobench_main() { cpu_bench( overhead, bench.get(), canvas, samples.get()); if (loops == 0) { - SkDebugf("Unable to time %s\t%s (overhead %s)\n", - bench->getName(), config, HUMANIZE(overhead)); + // Can't be timed. A warning note has already been printed. continue; }