diff options
author | 2014-07-15 17:56:37 -0400 | |
---|---|---|
committer | 2014-07-15 17:56:37 -0400 | |
commit | e3631364e93ee9164f3ce322778d5a50c33f63a6 (patch) | |
tree | ba69eb9594d6428edae6fbf0c98d735cfa15b738 /bench | |
parent | 184ff37c625f8a0588c6e27a24d2284bd70593df (diff) |
Try to debug Windows infinite loops in nanobench.
NOTREECHECKS=true
BUG=skia:
Review URL: https://codereview.chromium.org/396753004
Diffstat (limited to 'bench')
-rw-r--r-- | bench/nanobench.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 8f3d4aaf43..4453707416 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -50,6 +50,8 @@ DEFINE_bool(gpu, true, "Master switch for GPU-bound work."); DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each bench."); +DEFINE_int32(maxCalibrationAttempts, 3, + "Try up to this many times to guess loops for a bench, or skip the bench."); static SkString humanize(double ms) { @@ -93,9 +95,14 @@ static double estimate_timer_overhead() { 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; + int round = 0; do { bench_plus_overhead = time(1, bench, canvas, NULL); - } while (bench_plus_overhead < overhead); // Shouldn't normally happen. + if (++round == FLAGS_maxCalibrationAttempts) { + // At some point we have to just give up. + return 0; + } + } while (bench_plus_overhead < overhead); // Later we'll just start and stop the timer once but loop N times. // We'll pick N to make timer overhead negligible: @@ -306,6 +313,7 @@ int tool_main(int argc, char** argv) { bench->preDraw(); for (int j = 0; j < targets.count(); j++) { SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface->getCanvas() : NULL; + const char* config = targets[j]->config; const int loops = #if SK_SUPPORT_GPU @@ -315,10 +323,13 @@ int tool_main(int argc, char** argv) { #endif cpu_bench( overhead, bench.get(), canvas, samples.get()); - Stats stats(samples.get(), FLAGS_samples); - - const char* config = targets[j]->config; + if (loops == 0) { + SkDebugf("Unable to time %s\t%s (overhead %s)\n", + bench->getName(), config, humanize(overhead).c_str()); + continue; + } + Stats stats(samples.get(), FLAGS_samples); log.config(config); log.timer("min_ms", stats.min); log.timer("median_ms", stats.median); |