| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 kNormal_BenchMode, | 36 kNormal_BenchMode, |
| 37 kDeferred_BenchMode, | 37 kDeferred_BenchMode, |
| 38 kDeferredSilent_BenchMode, | 38 kDeferredSilent_BenchMode, |
| 39 kRecord_BenchMode, | 39 kRecord_BenchMode, |
| 40 kPictureRecord_BenchMode | 40 kPictureRecord_BenchMode |
| 41 }; | 41 }; |
| 42 const char* BenchMode_Name[] = { | 42 const char* BenchMode_Name[] = { |
| 43 "normal", "deferred", "deferredSilent", "record", "picturerecord" | 43 "normal", "deferred", "deferredSilent", "record", "picturerecord" |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 static const char kDefaultsConfigStr[] = "defaults"; |
| 47 |
| 46 /////////////////////////////////////////////////////////////////////////////// | 48 /////////////////////////////////////////////////////////////////////////////// |
| 47 | 49 |
| 48 static void erase(SkBitmap& bm) { | 50 static void erase(SkBitmap& bm) { |
| 49 if (bm.config() == SkBitmap::kA8_Config) { | 51 if (bm.config() == SkBitmap::kA8_Config) { |
| 50 bm.eraseColor(SK_ColorTRANSPARENT); | 52 bm.eraseColor(SK_ColorTRANSPARENT); |
| 51 } else { | 53 } else { |
| 52 bm.eraseColor(SK_ColorWHITE); | 54 bm.eraseColor(SK_ColorWHITE); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 "$ requires the end of the test to match\n" | 268 "$ requires the end of the test to match\n" |
| 267 "^ and $ requires an exact match\n" | 269 "^ and $ requires an exact match\n" |
| 268 "If a test does not match any list entry,\n" | 270 "If a test does not match any list entry,\n" |
| 269 "it is skipped unless some list entry starts with ~\n"
); | 271 "it is skipped unless some list entry starts with ~\n"
); |
| 270 DEFINE_string(mode, "normal", | 272 DEFINE_string(mode, "normal", |
| 271 "normal: draw to a normal canvas;\n" | 273 "normal: draw to a normal canvas;\n" |
| 272 "deferred: draw to a deferred canvas;\n" | 274 "deferred: draw to a deferred canvas;\n" |
| 273 "deferredSilent: deferred with silent playback;\n" | 275 "deferredSilent: deferred with silent playback;\n" |
| 274 "record: draw to an SkPicture;\n" | 276 "record: draw to an SkPicture;\n" |
| 275 "picturerecord: draw from an SkPicture to an SkPicture.\n"); | 277 "picturerecord: draw from an SkPicture to an SkPicture.\n"); |
| 276 DEFINE_string(config, "", "Run configs given. If empty, runs the defaults set i
n gConfigs."); | 278 DEFINE_string(config, kDefaultsConfigStr, |
| 279 "Run configs given. By default, runs the configs marked \"runByDe
fault\" in gConfigs."); |
| 277 DEFINE_string(logFile, "", "Also write stdout here."); | 280 DEFINE_string(logFile, "", "Also write stdout here."); |
| 278 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); | 281 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); |
| 279 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); | 282 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); |
| 280 DEFINE_double(error, 0.01, | 283 DEFINE_double(error, 0.01, |
| 281 "Ratio of subsequent bench measurements must drop within 1±error t
o converge."); | 284 "Ratio of subsequent bench measurements must drop within 1±error t
o converge."); |
| 282 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per
1000 loops."); | 285 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per
1000 loops."); |
| 283 DEFINE_bool2(verbose, v, false, "Print more."); | 286 DEFINE_bool2(verbose, v, false, "Print more."); |
| 284 | 287 |
| 285 // Has this bench converged? First arguments are milliseconds / loop iteration, | 288 // Has this bench converged? First arguments are milliseconds / loop iteration, |
| 286 // last is overall runtime in milliseconds. | 289 // last is overall runtime in milliseconds. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 317 } | 320 } |
| 318 | 321 |
| 319 BenchMode benchMode = kNormal_BenchMode; | 322 BenchMode benchMode = kNormal_BenchMode; |
| 320 for (size_t i = 0; i < SK_ARRAY_COUNT(BenchMode_Name); i++) { | 323 for (size_t i = 0; i < SK_ARRAY_COUNT(BenchMode_Name); i++) { |
| 321 if (strcmp(FLAGS_mode[0], BenchMode_Name[i]) == 0) { | 324 if (strcmp(FLAGS_mode[0], BenchMode_Name[i]) == 0) { |
| 322 benchMode = static_cast<BenchMode>(i); | 325 benchMode = static_cast<BenchMode>(i); |
| 323 } | 326 } |
| 324 } | 327 } |
| 325 | 328 |
| 326 SkTDArray<int> configs; | 329 SkTDArray<int> configs; |
| 330 bool runDefaultConfigs = false; |
| 327 // Try user-given configs first. | 331 // Try user-given configs first. |
| 328 for (int i = 0; i < FLAGS_config.count(); i++) { | 332 for (int i = 0; i < FLAGS_config.count(); i++) { |
| 329 for (size_t j = 0; j < SK_ARRAY_COUNT(gConfigs); j++) { | 333 for (size_t j = 0; j < SK_ARRAY_COUNT(gConfigs); j++) { |
| 330 if (0 == strcmp(FLAGS_config[i], gConfigs[j].name)) { | 334 if (0 == strcmp(FLAGS_config[i], gConfigs[j].name)) { |
| 331 *configs.append() = j; | 335 *configs.append() = j; |
| 336 } else if (0 == strcmp(FLAGS_config[i], kDefaultsConfigStr)) { |
| 337 runDefaultConfigs = true; |
| 332 } | 338 } |
| 333 } | 339 } |
| 334 } | 340 } |
| 335 // If there weren't any, fill in with defaults. | 341 // If there weren't any, fill in with defaults. |
| 336 if (configs.count() == 0) { | 342 if (runDefaultConfigs) { |
| 337 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { | 343 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { |
| 338 if (gConfigs[i].runByDefault) { | 344 if (gConfigs[i].runByDefault) { |
| 339 *configs.append() = i; | 345 *configs.append() = i; |
| 340 } | 346 } |
| 341 } | 347 } |
| 342 } | 348 } |
| 343 // Filter out things we can't run. | 349 // Filter out things we can't run. |
| 344 if (kNormal_BenchMode != benchMode) { | 350 if (kNormal_BenchMode != benchMode) { |
| 345 // Non-rendering configs only run in normal mode | 351 // Non-rendering configs only run in normal mode |
| 346 for (int i = 0; i < configs.count(); ++i) { | 352 for (int i = 0; i < configs.count(); ++i) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 gContextFactory.destroyContexts(); | 658 gContextFactory.destroyContexts(); |
| 653 #endif | 659 #endif |
| 654 return 0; | 660 return 0; |
| 655 } | 661 } |
| 656 | 662 |
| 657 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 663 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 658 int main(int argc, char * const argv[]) { | 664 int main(int argc, char * const argv[]) { |
| 659 return tool_main(argc, (char**) argv); | 665 return tool_main(argc, (char**) argv); |
| 660 } | 666 } |
| 661 #endif | 667 #endif |
| OLD | NEW |