Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: bench/nanobench.cpp

Issue 431503004: Fix calibration loop failure condition. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/nanobench.cpp
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 811fc7f7e91fe2c933cfb82b651041e0faceeba2..2dfd33f594abea06cf4034dc34ffcafc0b7687a4 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698