| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_bool(runOnce, kIsDebug, "Run each bench exactly once and don't report tim
ings."); |
| 265 DEFINE_double(error, 0.01, | 265 DEFINE_double(error, 0.01, |
| 266 "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."); |
| 267 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."); |
| 268 DEFINE_bool2(verbose, v, false, "Print more."); | 268 DEFINE_bool2(verbose, v, false, "Print more."); |
| 269 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | 269 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); |
| 270 #ifdef SK_BUILD_JSON_WRITER |
| 270 DEFINE_string(outResultsFile, "", "If given, the results will be written to the
file in JSON format."); | 271 DEFINE_string(outResultsFile, "", "If given, the results will be written to the
file in JSON format."); |
| 271 | 272 #endif |
| 272 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
have been done."); | 273 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
have been done."); |
| 273 | 274 |
| 274 // Has this bench converged? First arguments are milliseconds / loop iteration, | 275 // Has this bench converged? First arguments are milliseconds / loop iteration, |
| 275 // last is overall runtime in milliseconds. | 276 // last is overall runtime in milliseconds. |
| 276 static bool HasConverged(double prevPerLoop, double currPerLoop, double currRaw)
{ | 277 static bool HasConverged(double prevPerLoop, double currPerLoop, double currRaw)
{ |
| 277 if (currRaw < FLAGS_minMs) { | 278 if (currRaw < FLAGS_minMs) { |
| 278 return false; | 279 return false; |
| 279 } | 280 } |
| 280 const double low = 1 - FLAGS_error, high = 1 + FLAGS_error; | 281 const double low = 1 - FLAGS_error, high = 1 + FLAGS_error; |
| 281 const double ratio = currPerLoop / prevPerLoop; | 282 const double ratio = currPerLoop / prevPerLoop; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 294 | 295 |
| 295 // First, parse some flags. | 296 // First, parse some flags. |
| 296 SkBenchLogger logger; | 297 SkBenchLogger logger; |
| 297 if (FLAGS_logFile.count()) { | 298 if (FLAGS_logFile.count()) { |
| 298 logger.SetLogFile(FLAGS_logFile[0]); | 299 logger.SetLogFile(FLAGS_logFile[0]); |
| 299 } | 300 } |
| 300 | 301 |
| 301 LoggerResultsWriter logWriter(logger, FLAGS_timeFormat[0]); | 302 LoggerResultsWriter logWriter(logger, FLAGS_timeFormat[0]); |
| 302 MultiResultsWriter writer; | 303 MultiResultsWriter writer; |
| 303 writer.add(&logWriter); | 304 writer.add(&logWriter); |
| 305 |
| 306 #ifdef SK_BUILD_JSON_WRITER |
| 304 SkAutoTDelete<JSONResultsWriter> jsonWriter; | 307 SkAutoTDelete<JSONResultsWriter> jsonWriter; |
| 305 if (FLAGS_outResultsFile.count()) { | 308 if (FLAGS_outResultsFile.count()) { |
| 306 jsonWriter.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0]))); | 309 jsonWriter.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0]))); |
| 307 writer.add(jsonWriter.get()); | 310 writer.add(jsonWriter.get()); |
| 308 } | 311 } |
| 312 #endif |
| 313 |
| 309 // Instantiate after all the writers have been added to writer so that we | 314 // Instantiate after all the writers have been added to writer so that we |
| 310 // call close() before their destructors are called on the way out. | 315 // call close() before their destructors are called on the way out. |
| 311 CallEnd<MultiResultsWriter> ender(writer); | 316 CallEnd<MultiResultsWriter> ender(writer); |
| 312 | 317 |
| 313 const uint8_t alpha = FLAGS_forceBlend ? 0x80 : 0xFF; | 318 const uint8_t alpha = FLAGS_forceBlend ? 0x80 : 0xFF; |
| 314 SkTriState::State dither = SkTriState::kDefault; | 319 SkTriState::State dither = SkTriState::kDefault; |
| 315 for (size_t i = 0; i < 3; i++) { | 320 for (size_t i = 0; i < 3; i++) { |
| 316 if (strcmp(SkTriState::Name[i], FLAGS_forceDither[0]) == 0) { | 321 if (strcmp(SkTriState::Name[i], FLAGS_forceDither[0]) == 0) { |
| 317 dither = static_cast<SkTriState::State>(i); | 322 dither = static_cast<SkTriState::State>(i); |
| 318 } | 323 } |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 gContextFactory.destroyContexts(); | 703 gContextFactory.destroyContexts(); |
| 699 #endif | 704 #endif |
| 700 return 0; | 705 return 0; |
| 701 } | 706 } |
| 702 | 707 |
| 703 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 708 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 704 int main(int argc, char * const argv[]) { | 709 int main(int argc, char * const argv[]) { |
| 705 return tool_main(argc, (char**) argv); | 710 return tool_main(argc, (char**) argv); |
| 706 } | 711 } |
| 707 #endif | 712 #endif |
| OLD | NEW |