| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 config.sampleCount, config.name)); | 381 config.sampleCount, config.name)); |
| 381 configs.remove(i); | 382 configs.remove(i); |
| 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 (FLAGS_runOnce) { |
| 391 logger.logError("bench was built in Debug mode, so we're going to hide t
he times." | 392 logger.logError("bench was run with --runOnce, so we're going to hide th
e times." |
| 392 " It's for your own good!\n"); | 393 " It's for your own good!\n"); |
| 393 } | 394 } |
| 394 writer.option("mode", FLAGS_mode[0]); | 395 writer.option("mode", FLAGS_mode[0]); |
| 395 writer.option("alpha", SkStringPrintf("0x%02X", alpha).c_str()); | 396 writer.option("alpha", SkStringPrintf("0x%02X", alpha).c_str()); |
| 396 writer.option("antialias", SkStringPrintf("%d", FLAGS_forceAA).c_str()); | 397 writer.option("antialias", SkStringPrintf("%d", FLAGS_forceAA).c_str()); |
| 397 writer.option("filter", SkStringPrintf("%d", FLAGS_forceFilter).c_str()); | 398 writer.option("filter", SkStringPrintf("%d", FLAGS_forceFilter).c_str()); |
| 398 writer.option("dither", SkTriState::Name[dither]); | 399 writer.option("dither", SkTriState::Name[dither]); |
| 399 | 400 |
| 400 writer.option("rotate", SkStringPrintf("%d", FLAGS_rotate).c_str()); | 401 writer.option("rotate", SkStringPrintf("%d", FLAGS_rotate).c_str()); |
| 401 writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str()); | 402 writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str()); |
| 402 writer.option("clip", SkStringPrintf("%d", FLAGS_clip).c_str()); | 403 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
, | 653 // bench->getName(), frameIntervalTotalLoops
, |
| 653 // timer.fWall, loopsPerFrame); | 654 // timer.fWall, loopsPerFrame); |
| 654 } | 655 } |
| 655 } | 656 } |
| 656 | 657 |
| 657 const double current = timer.fWall / loopsPerIter; | 658 const double current = timer.fWall / loopsPerIter; |
| 658 if (FLAGS_verbose && current > previous) { SkDebugf("↑"); } | 659 if (FLAGS_verbose && current > previous) { SkDebugf("↑"); } |
| 659 if (FLAGS_verbose) { SkDebugf("%.3g ", current); } | 660 if (FLAGS_verbose) { SkDebugf("%.3g ", current); } |
| 660 converged = HasConverged(previous, current, timer.fWall); | 661 converged = HasConverged(previous, current, timer.fWall); |
| 661 previous = current; | 662 previous = current; |
| 662 } while (!kIsDebug && !converged); | 663 } while (!FLAGS_runOnce && !converged); |
| 663 } | 664 } |
| 664 if (FLAGS_verbose) { SkDebugf("\n"); } | 665 if (FLAGS_verbose) { SkDebugf("\n"); } |
| 665 | 666 |
| 666 if (!FLAGS_dryRun && FLAGS_outDir.count() && SkBenchmark::kNonRender
ing_Backend != config.backend) { | 667 if (!FLAGS_dryRun && FLAGS_outDir.count() && SkBenchmark::kNonRender
ing_Backend != config.backend) { |
| 667 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 668 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
| 668 if (image.get()) { | 669 if (image.get()) { |
| 669 saveFile(bench->getName(), config.name, FLAGS_outDir[0], | 670 saveFile(bench->getName(), config.name, FLAGS_outDir[0], |
| 670 image); | 671 image); |
| 671 } | 672 } |
| 672 } | 673 } |
| 673 | 674 |
| 674 if (kIsDebug) { | 675 if (FLAGS_runOnce) { |
| 675 // Let's not mislead ourselves by looking at Debug build bench t
imes! | 676 // Let's not mislead ourselves by looking at Debug build or sing
le iteration bench times! |
| 676 continue; | 677 continue; |
| 677 } | 678 } |
| 678 | 679 |
| 679 // Normalize to ms per 1000 iterations. | 680 // Normalize to ms per 1000 iterations. |
| 680 const double normalize = 1000.0 / loopsPerIter; | 681 const double normalize = 1000.0 / loopsPerIter; |
| 681 const struct { char shortName; const char* longName; double ms; } ti
mes[] = { | 682 const struct { char shortName; const char* longName; double ms; } ti
mes[] = { |
| 682 {'w', "msecs", normalize * timer.fWall}, | 683 {'w', "msecs", normalize * timer.fWall}, |
| 683 {'W', "Wmsecs", normalize * timer.fTruncatedWall}, | 684 {'W', "Wmsecs", normalize * timer.fTruncatedWall}, |
| 684 {'c', "cmsecs", normalize * timer.fCpu}, | 685 {'c', "cmsecs", normalize * timer.fCpu}, |
| 685 {'C', "Cmsecs", normalize * timer.fTruncatedCpu}, | 686 {'C', "Cmsecs", normalize * timer.fTruncatedCpu}, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 698 gContextFactory.destroyContexts(); | 699 gContextFactory.destroyContexts(); |
| 699 #endif | 700 #endif |
| 700 return 0; | 701 return 0; |
| 701 } | 702 } |
| 702 | 703 |
| 703 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 704 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 704 int main(int argc, char * const argv[]) { | 705 int main(int argc, char * const argv[]) { |
| 705 return tool_main(argc, (char**) argv); | 706 return tool_main(argc, (char**) argv); |
| 706 } | 707 } |
| 707 #endif | 708 #endif |
| OLD | NEW |