OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "BenchTimer.h" | 8 #include "BenchTimer.h" |
9 #include "ResultsWriter.h" | 9 #include "ResultsWriter.h" |
10 #include "SkBenchLogger.h" | 10 #include "SkBenchLogger.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 "normal: draw to a normal canvas;\n" | 254 "normal: draw to a normal canvas;\n" |
255 "deferred: draw to a deferred canvas;\n" | 255 "deferred: draw to a deferred canvas;\n" |
256 "deferredSilent: deferred with silent playback;\n" | 256 "deferredSilent: deferred with silent playback;\n" |
257 "record: draw to an SkPicture;\n" | 257 "record: draw to an SkPicture;\n" |
258 "picturerecord: draw from an SkPicture to an SkPicture.\n"); | 258 "picturerecord: draw from an SkPicture to an SkPicture.\n"); |
259 DEFINE_string(config, kDefaultsConfigStr, | 259 DEFINE_string(config, kDefaultsConfigStr, |
260 "Run configs given. By default, runs the configs marked \"runByDe fault\" in gConfigs."); | 260 "Run configs given. By default, runs the configs marked \"runByDe fault\" in gConfigs."); |
261 DEFINE_string(logFile, "", "Also write stdout here."); | 261 DEFINE_string(logFile, "", "Also write stdout here."); |
262 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); | 262 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); |
263 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); | 263 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); |
264 DEFINE_bool(runOnce, kIsDebug, "Run each bench exactly once and don't report tim ings."); | |
264 DEFINE_double(error, 0.01, | 265 DEFINE_double(error, 0.01, |
265 "Ratio of subsequent bench measurements must drop within 1±error t o converge."); | 266 "Ratio of subsequent bench measurements must drop within 1±error t o converge."); |
266 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per 1000 loops."); | 267 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per 1000 loops."); |
267 DEFINE_bool2(verbose, v, false, "Print more."); | 268 DEFINE_bool2(verbose, v, false, "Print more."); |
268 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | 269 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); |
269 DEFINE_string(outResultsFile, "", "If given, the results will be written to the file in JSON format."); | 270 DEFINE_string(outResultsFile, "", "If given, the results will be written to the file in JSON format."); |
270 | 271 |
271 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would have been done."); | 272 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would have been done."); |
272 | 273 |
273 // Has this bench converged? First arguments are milliseconds / loop iteration, | 274 // Has this bench converged? First arguments are milliseconds / loop iteration, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 --i; | 383 --i; |
383 continue; | 384 continue; |
384 } | 385 } |
385 } | 386 } |
386 } | 387 } |
387 #endif | 388 #endif |
388 | 389 |
389 // All flags should be parsed now. Report our settings. | 390 // All flags should be parsed now. Report our settings. |
390 if (kIsDebug) { | 391 if (kIsDebug) { |
391 logger.logError("bench was built in Debug mode, so we're going to hide t he times." | 392 logger.logError("bench was built in Debug mode, so we're going to hide t he times." |
392 " It's for your own good!\n"); | 393 " It's for your own good!\n"); |
394 } else if (FLAGS_runOnce) { | |
395 logger.logError("bench was run with --runOnce, so we're going to hide th e times." | |
396 " It's for your own good!\n"); | |
393 } | 397 } |
394 writer.option("mode", FLAGS_mode[0]); | 398 writer.option("mode", FLAGS_mode[0]); |
395 writer.option("alpha", SkStringPrintf("0x%02X", alpha).c_str()); | 399 writer.option("alpha", SkStringPrintf("0x%02X", alpha).c_str()); |
396 writer.option("antialias", SkStringPrintf("%d", FLAGS_forceAA).c_str()); | 400 writer.option("antialias", SkStringPrintf("%d", FLAGS_forceAA).c_str()); |
397 writer.option("filter", SkStringPrintf("%d", FLAGS_forceFilter).c_str()); | 401 writer.option("filter", SkStringPrintf("%d", FLAGS_forceFilter).c_str()); |
398 writer.option("dither", SkTriState::Name[dither]); | 402 writer.option("dither", SkTriState::Name[dither]); |
399 | 403 |
400 writer.option("rotate", SkStringPrintf("%d", FLAGS_rotate).c_str()); | 404 writer.option("rotate", SkStringPrintf("%d", FLAGS_rotate).c_str()); |
401 writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str()); | 405 writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str()); |
402 writer.option("clip", SkStringPrintf("%d", FLAGS_clip).c_str()); | 406 writer.option("clip", SkStringPrintf("%d", FLAGS_clip).c_str()); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 // bench->getName(), frameIntervalTotalLoops , | 656 // bench->getName(), frameIntervalTotalLoops , |
653 // timer.fWall, loopsPerFrame); | 657 // timer.fWall, loopsPerFrame); |
654 } | 658 } |
655 } | 659 } |
656 | 660 |
657 const double current = timer.fWall / loopsPerIter; | 661 const double current = timer.fWall / loopsPerIter; |
658 if (FLAGS_verbose && current > previous) { SkDebugf("↑"); } | 662 if (FLAGS_verbose && current > previous) { SkDebugf("↑"); } |
659 if (FLAGS_verbose) { SkDebugf("%.3g ", current); } | 663 if (FLAGS_verbose) { SkDebugf("%.3g ", current); } |
660 converged = HasConverged(previous, current, timer.fWall); | 664 converged = HasConverged(previous, current, timer.fWall); |
661 previous = current; | 665 previous = current; |
662 } while (!kIsDebug && !converged); | 666 } while (!FLAGS_runOnce && !converged); |
663 } | 667 } |
664 if (FLAGS_verbose) { SkDebugf("\n"); } | 668 if (FLAGS_verbose) { SkDebugf("\n"); } |
665 | 669 |
666 if (!FLAGS_dryRun && FLAGS_outDir.count() && SkBenchmark::kNonRender ing_Backend != config.backend) { | 670 if (!FLAGS_dryRun && FLAGS_outDir.count() && SkBenchmark::kNonRender ing_Backend != config.backend) { |
667 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 671 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
668 if (image.get()) { | 672 if (image.get()) { |
669 saveFile(bench->getName(), config.name, FLAGS_outDir[0], | 673 saveFile(bench->getName(), config.name, FLAGS_outDir[0], |
670 image); | 674 image); |
671 } | 675 } |
672 } | 676 } |
673 | 677 |
674 if (kIsDebug) { | 678 if (kIsDebug || FLAGS_runOnce) { |
mtklein
2014/04/21 20:04:16
Let's just fold it into one bool? It's really the
bsalomon
2014/04/21 20:42:50
Done.
| |
675 // Let's not mislead ourselves by looking at Debug build bench t imes! | 679 // Let's not mislead ourselves by looking at Debug build or sing le iteration bench times! |
676 continue; | 680 continue; |
677 } | 681 } |
678 | 682 |
679 // Normalize to ms per 1000 iterations. | 683 // Normalize to ms per 1000 iterations. |
680 const double normalize = 1000.0 / loopsPerIter; | 684 const double normalize = 1000.0 / loopsPerIter; |
681 const struct { char shortName; const char* longName; double ms; } ti mes[] = { | 685 const struct { char shortName; const char* longName; double ms; } ti mes[] = { |
682 {'w', "msecs", normalize * timer.fWall}, | 686 {'w', "msecs", normalize * timer.fWall}, |
683 {'W', "Wmsecs", normalize * timer.fTruncatedWall}, | 687 {'W', "Wmsecs", normalize * timer.fTruncatedWall}, |
684 {'c', "cmsecs", normalize * timer.fCpu}, | 688 {'c', "cmsecs", normalize * timer.fCpu}, |
685 {'C', "Cmsecs", normalize * timer.fTruncatedCpu}, | 689 {'C', "Cmsecs", normalize * timer.fTruncatedCpu}, |
(...skipping 12 matching lines...) Expand all Loading... | |
698 gContextFactory.destroyContexts(); | 702 gContextFactory.destroyContexts(); |
699 #endif | 703 #endif |
700 return 0; | 704 return 0; |
701 } | 705 } |
702 | 706 |
703 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 707 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
704 int main(int argc, char * const argv[]) { | 708 int main(int argc, char * const argv[]) { |
705 return tool_main(argc, (char**) argv); | 709 return tool_main(argc, (char**) argv); |
706 } | 710 } |
707 #endif | 711 #endif |
OLD | NEW |