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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 DEFINE_string(config, kDefaultsConfigStr, | 247 DEFINE_string(config, kDefaultsConfigStr, |
248 "Run configs given. By default, runs the configs marked \"runByDe
fault\" in gConfigs."); | 248 "Run configs given. By default, runs the configs marked \"runByDe
fault\" in gConfigs."); |
249 DEFINE_string(logFile, "", "Also write stdout here."); | 249 DEFINE_string(logFile, "", "Also write stdout here."); |
250 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); | 250 DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run."); |
251 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); | 251 DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run."); |
252 DEFINE_bool(runOnce, kIsDebug, "Run each bench exactly once and don't report tim
ings."); | 252 DEFINE_bool(runOnce, kIsDebug, "Run each bench exactly once and don't report tim
ings."); |
253 DEFINE_double(error, 0.01, | 253 DEFINE_double(error, 0.01, |
254 "Ratio of subsequent bench measurements must drop within 1±error t
o converge."); | 254 "Ratio of subsequent bench measurements must drop within 1±error t
o converge."); |
255 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per
1000 loops."); | 255 DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per
1000 loops."); |
256 DEFINE_bool2(verbose, v, false, "Print more."); | 256 DEFINE_bool2(verbose, v, false, "Print more."); |
257 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | |
258 #ifdef SK_BUILD_JSON_WRITER | 257 #ifdef SK_BUILD_JSON_WRITER |
259 DEFINE_string(outResultsFile, "", "If given, the results will be written to the
file in JSON format."); | 258 DEFINE_string(outResultsFile, "", "If given, the results will be written to the
file in JSON format."); |
260 #endif | 259 #endif |
261 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
have been done."); | 260 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
have been done."); |
262 | 261 |
263 // Has this bench converged? First arguments are milliseconds / loop iteration, | 262 // Has this bench converged? First arguments are milliseconds / loop iteration, |
264 // last is overall runtime in milliseconds. | 263 // last is overall runtime in milliseconds. |
265 static bool HasConverged(double prevPerLoop, double currPerLoop, double currRaw)
{ | 264 static bool HasConverged(double prevPerLoop, double currPerLoop, double currRaw)
{ |
266 if (currRaw < FLAGS_minMs) { | 265 if (currRaw < FLAGS_minMs) { |
267 return false; | 266 return false; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 if (kNormal_BenchMode != benchMode) { | 341 if (kNormal_BenchMode != benchMode) { |
343 // Non-rendering configs only run in normal mode | 342 // Non-rendering configs only run in normal mode |
344 for (int i = 0; i < configs.count(); ++i) { | 343 for (int i = 0; i < configs.count(); ++i) { |
345 const Config& config = gConfigs[configs[i]]; | 344 const Config& config = gConfigs[configs[i]]; |
346 if (SkBenchmark::kNonRendering_Backend == config.backend) { | 345 if (SkBenchmark::kNonRendering_Backend == config.backend) { |
347 configs.remove(i, 1); | 346 configs.remove(i, 1); |
348 --i; | 347 --i; |
349 } | 348 } |
350 } | 349 } |
351 } | 350 } |
352 // Set the resource path. | |
353 if (!FLAGS_resourcePath.isEmpty()) { | |
354 SkBenchmark::SetResourcePath(FLAGS_resourcePath[0]); | |
355 } | |
356 | 351 |
357 #if SK_SUPPORT_GPU | 352 #if SK_SUPPORT_GPU |
358 for (int i = 0; i < configs.count(); ++i) { | 353 for (int i = 0; i < configs.count(); ++i) { |
359 const Config& config = gConfigs[configs[i]]; | 354 const Config& config = gConfigs[configs[i]]; |
360 | 355 |
361 if (SkBenchmark::kGPU_Backend == config.backend) { | 356 if (SkBenchmark::kGPU_Backend == config.backend) { |
362 GrContext* context = gContextFactory.get(config.contextType); | 357 GrContext* context = gContextFactory.get(config.contextType); |
363 if (NULL == context) { | 358 if (NULL == context) { |
364 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", | 359 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", |
365 config.name); | 360 config.name); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 gContextFactory.destroyContexts(); | 679 gContextFactory.destroyContexts(); |
685 #endif | 680 #endif |
686 return 0; | 681 return 0; |
687 } | 682 } |
688 | 683 |
689 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 684 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
690 int main(int argc, char * const argv[]) { | 685 int main(int argc, char * const argv[]) { |
691 return tool_main(argc, (char**) argv); | 686 return tool_main(argc, (char**) argv); |
692 } | 687 } |
693 #endif | 688 #endif |
OLD | NEW |