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

Side by Side Diff: bench/nanobench.cpp

Issue 396753004: Try to debug Windows infinite loops in nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <ctype.h> 8 #include <ctype.h>
9 9
10 #include "Benchmark.h" 10 #include "Benchmark.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DEFINE_string(config, "nonrendering 8888 gpu", "Configs to measure. Options: " 43 DEFINE_string(config, "nonrendering 8888 gpu", "Configs to measure. Options: "
44 "565 8888 gpu nonrendering debug nullgpu msaa4 msaa16 nvprmsaa4 nv prmsaa16 angle"); 44 "565 8888 gpu nonrendering debug nullgpu msaa4 msaa16 nvprmsaa4 nv prmsaa16 angle");
45 DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU."); 45 DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
46 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag."); 46 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag.");
47 47
48 DEFINE_bool(cpu, true, "Master switch for CPU-bound work."); 48 DEFINE_bool(cpu, true, "Master switch for CPU-bound work.");
49 DEFINE_bool(gpu, true, "Master switch for GPU-bound work."); 49 DEFINE_bool(gpu, true, "Master switch for GPU-bound work.");
50 50
51 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); 51 DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
52 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each benc h."); 52 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each benc h.");
53 DEFINE_int32(maxCalibrationAttempts, 3,
54 "Try up to this many times to guess loops for a bench, or skip the bench.");
53 55
54 56
55 static SkString humanize(double ms) { 57 static SkString humanize(double ms) {
56 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); 58 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
57 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); 59 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
58 #ifdef SK_BUILD_FOR_WIN 60 #ifdef SK_BUILD_FOR_WIN
59 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); 61 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3);
60 #else 62 #else
61 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); 63 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3);
62 #endif 64 #endif
(...skipping 23 matching lines...) Expand all
86 double overhead = 0; 88 double overhead = 0;
87 for (int i = 0; i < FLAGS_overheadLoops; i++) { 89 for (int i = 0; i < FLAGS_overheadLoops; i++) {
88 overhead += time(1, NULL, NULL, NULL); 90 overhead += time(1, NULL, NULL, NULL);
89 } 91 }
90 return overhead / FLAGS_overheadLoops; 92 return overhead / FLAGS_overheadLoops;
91 } 93 }
92 94
93 static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, double* samples) { 95 static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, double* samples) {
94 // First figure out approximately how many loops of bench it takes to make o verhead negligible. 96 // First figure out approximately how many loops of bench it takes to make o verhead negligible.
95 double bench_plus_overhead; 97 double bench_plus_overhead;
98 int round = 0;
96 do { 99 do {
97 bench_plus_overhead = time(1, bench, canvas, NULL); 100 bench_plus_overhead = time(1, bench, canvas, NULL);
98 } while (bench_plus_overhead < overhead); // Shouldn't normally happen. 101 if (++round == FLAGS_maxCalibrationAttempts) {
102 // At some point we have to just give up.
103 return 0;
104 }
105 } while (bench_plus_overhead < overhead);
99 106
100 // Later we'll just start and stop the timer once but loop N times. 107 // Later we'll just start and stop the timer once but loop N times.
101 // We'll pick N to make timer overhead negligible: 108 // We'll pick N to make timer overhead negligible:
102 // 109 //
103 // overhead 110 // overhead
104 // ------------------------- < FLAGS_overheadGoal 111 // ------------------------- < FLAGS_overheadGoal
105 // overhead + N * Bench Time 112 // overhead + N * Bench Time
106 // 113 //
107 // where bench_plus_overhead ≈ overhead + Bench Time. 114 // where bench_plus_overhead ≈ overhead + Bench Time.
108 // 115 //
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 continue; 306 continue;
300 } 307 }
301 log.bench(bench->getName(), bench->getSize().fX, bench->getSize().fY); 308 log.bench(bench->getName(), bench->getSize().fX, bench->getSize().fY);
302 309
303 SkTDArray<Target*> targets; 310 SkTDArray<Target*> targets;
304 create_targets(bench.get(), &targets); 311 create_targets(bench.get(), &targets);
305 312
306 bench->preDraw(); 313 bench->preDraw();
307 for (int j = 0; j < targets.count(); j++) { 314 for (int j = 0; j < targets.count(); j++) {
308 SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface-> getCanvas() : NULL; 315 SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface-> getCanvas() : NULL;
316 const char* config = targets[j]->config;
309 317
310 const int loops = 318 const int loops =
311 #if SK_SUPPORT_GPU 319 #if SK_SUPPORT_GPU
312 Benchmark::kGPU_Backend == targets[j]->backend 320 Benchmark::kGPU_Backend == targets[j]->backend
313 ? gpu_bench(targets[j]->gl, bench.get(), canvas, samples.get()) 321 ? gpu_bench(targets[j]->gl, bench.get(), canvas, samples.get())
314 : 322 :
315 #endif 323 #endif
316 cpu_bench( overhead, bench.get(), canvas, samples.get()); 324 cpu_bench( overhead, bench.get(), canvas, samples.get());
317 325
326 if (loops == 0) {
327 SkDebugf("Unable to time %s\t%s (overhead %s)\n",
328 bench->getName(), config, humanize(overhead).c_str());
329 continue;
330 }
331
318 Stats stats(samples.get(), FLAGS_samples); 332 Stats stats(samples.get(), FLAGS_samples);
319
320 const char* config = targets[j]->config;
321
322 log.config(config); 333 log.config(config);
323 log.timer("min_ms", stats.min); 334 log.timer("min_ms", stats.min);
324 log.timer("median_ms", stats.median); 335 log.timer("median_ms", stats.median);
325 log.timer("mean_ms", stats.mean); 336 log.timer("mean_ms", stats.mean);
326 log.timer("max_ms", stats.max); 337 log.timer("max_ms", stats.max);
327 log.timer("stddev_ms", sqrt(stats.var)); 338 log.timer("stddev_ms", sqrt(stats.var));
328 339
329 if (FLAGS_runOnce) { 340 if (FLAGS_runOnce) {
330 if (targets.count() == 1) { 341 if (targets.count() == 1) {
331 config = ""; // Only print the config if we run the same ben ch on more than one. 342 config = ""; // Only print the config if we run the same ben ch on more than one.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 377 }
367 378
368 return 0; 379 return 0;
369 } 380 }
370 381
371 #if !defined SK_BUILD_FOR_IOS 382 #if !defined SK_BUILD_FOR_IOS
372 int main(int argc, char * const argv[]) { 383 int main(int argc, char * const argv[]) {
373 return tool_main(argc, (char**) argv); 384 return tool_main(argc, (char**) argv);
374 } 385 }
375 #endif 386 #endif
OLDNEW
« 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