| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 <ctype.h> | 8 #include <ctype.h> |
| 9 | 9 |
| 10 #include "Benchmark.h" | 10 #include "Benchmark.h" |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { | 469 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { |
| 470 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS
_scales[i]); | 470 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS
_scales[i]); |
| 471 exit(1); | 471 exit(1); |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 fUseMPDs.push_back() = false; | 475 fUseMPDs.push_back() = false; |
| 476 if (FLAGS_mpd) { | 476 if (FLAGS_mpd) { |
| 477 fUseMPDs.push_back() = true; | 477 fUseMPDs.push_back() = true; |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Prepare the images for decoding | 480 // Prepare the images for decoding |
| 481 for (int i = 0; i < FLAGS_images.count(); i++) { | 481 for (int i = 0; i < FLAGS_images.count(); i++) { |
| 482 const char* flag = FLAGS_images[i]; | 482 const char* flag = FLAGS_images[i]; |
| 483 if (sk_isdir(flag)) { | 483 if (sk_isdir(flag)) { |
| 484 // If the value passed in is a directory, add all the images | 484 // If the value passed in is a directory, add all the images |
| 485 SkOSFile::Iter it(flag); | 485 SkOSFile::Iter it(flag); |
| 486 SkString file; | 486 SkString file; |
| 487 while (it.next(&file)) { | 487 while (it.next(&file)) { |
| 488 fImages.push_back() = SkOSPath::Join(flag, file.c_str()); | 488 fImages.push_back() = SkOSPath::Join(flag, file.c_str()); |
| 489 } | 489 } |
| 490 } else if (sk_exists(flag)) { | 490 } else if (sk_exists(flag)) { |
| 491 // Also add the value if it is a single image | 491 // Also add the value if it is a single image |
| 492 fImages.push_back() = flag; | 492 fImages.push_back() = flag; |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 | 495 |
| 496 // Choose the candidate color types for image decoding | 496 // Choose the candidate color types for image decoding |
| 497 const SkColorType colorTypes[] = | 497 const SkColorType colorTypes[] = |
| 498 { kN32_SkColorType, kRGB_565_SkColorType, kAlpha_8_SkColorType }; | 498 { kN32_SkColorType, kRGB_565_SkColorType, kAlpha_8_SkColorType }; |
| 499 fColorTypes.push_back_n(SK_ARRAY_COUNT(colorTypes), colorTypes); | 499 fColorTypes.push_back_n(SK_ARRAY_COUNT(colorTypes), colorTypes); |
| 500 } | 500 } |
| 501 | 501 |
| 502 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { | 502 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { |
| 503 // Not strictly necessary, as it will be checked again later, | 503 // Not strictly necessary, as it will be checked again later, |
| 504 // but helps to avoid a lot of pointless work if we're going to skip it. | 504 // but helps to avoid a lot of pointless work if we're going to skip it. |
| 505 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { | 505 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 log->metric("min_ms", stats.min); | 835 log->metric("min_ms", stats.min); |
| 836 if (runs++ % FLAGS_flushEvery == 0) { | 836 if (runs++ % FLAGS_flushEvery == 0) { |
| 837 log->flush(); | 837 log->flush(); |
| 838 } | 838 } |
| 839 | 839 |
| 840 if (kAutoTuneLoops != FLAGS_loops) { | 840 if (kAutoTuneLoops != FLAGS_loops) { |
| 841 if (targets.count() == 1) { | 841 if (targets.count() == 1) { |
| 842 config = ""; // Only print the config if we run the same ben
ch on more than one. | 842 config = ""; // Only print the config if we run the same ben
ch on more than one. |
| 843 } | 843 } |
| 844 SkDebugf("%4dM\t%s\t%s\n" | 844 SkDebugf("%4dM\t%s\t%s\n" |
| 845 , sk_tools::getMaxResidentSetSizeMB() | 845 , sk_tools::getBestResidentSetSizeMB() |
| 846 , bench->getUniqueName() | 846 , bench->getUniqueName() |
| 847 , config); | 847 , config); |
| 848 } else if (FLAGS_verbose) { | 848 } else if (FLAGS_verbose) { |
| 849 for (int i = 0; i < FLAGS_samples; i++) { | 849 for (int i = 0; i < FLAGS_samples; i++) { |
| 850 SkDebugf("%s ", HUMANIZE(samples[i])); | 850 SkDebugf("%s ", HUMANIZE(samples[i])); |
| 851 } | 851 } |
| 852 SkDebugf("%s\n", bench->getUniqueName()); | 852 SkDebugf("%s\n", bench->getUniqueName()); |
| 853 } else if (FLAGS_quiet) { | 853 } else if (FLAGS_quiet) { |
| 854 if (targets.count() == 1) { | 854 if (targets.count() == 1) { |
| 855 config = ""; // Only print the config if we run the same ben
ch on more than one. | 855 config = ""; // Only print the config if we run the same ben
ch on more than one. |
| 856 } | 856 } |
| 857 SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getUniqu
eName(), config); | 857 SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getUniqu
eName(), config); |
| 858 } else { | 858 } else { |
| 859 const double stddev_percent = 100 * sqrt(stats.var) / stats.mean
; | 859 const double stddev_percent = 100 * sqrt(stats.var) / stats.mean
; |
| 860 SkDebugf("%4dM\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n" | 860 SkDebugf("%4dM\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n" |
| 861 , sk_tools::getMaxResidentSetSizeMB() | 861 , sk_tools::getBestResidentSetSizeMB() |
| 862 , loops | 862 , loops |
| 863 , HUMANIZE(stats.min) | 863 , HUMANIZE(stats.min) |
| 864 , HUMANIZE(stats.median) | 864 , HUMANIZE(stats.median) |
| 865 , HUMANIZE(stats.mean) | 865 , HUMANIZE(stats.mean) |
| 866 , HUMANIZE(stats.max) | 866 , HUMANIZE(stats.max) |
| 867 , stddev_percent | 867 , stddev_percent |
| 868 , stats.plot.c_str() | 868 , stats.plot.c_str() |
| 869 , config | 869 , config |
| 870 , bench->getUniqueName() | 870 , bench->getUniqueName() |
| 871 ); | 871 ); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 896 | 896 |
| 897 return 0; | 897 return 0; |
| 898 } | 898 } |
| 899 | 899 |
| 900 #if !defined SK_BUILD_FOR_IOS | 900 #if !defined SK_BUILD_FOR_IOS |
| 901 int main(int argc, char** argv) { | 901 int main(int argc, char** argv) { |
| 902 SkCommandLineFlags::Parse(argc, argv); | 902 SkCommandLineFlags::Parse(argc, argv); |
| 903 return nanobench_main(); | 903 return nanobench_main(); |
| 904 } | 904 } |
| 905 #endif | 905 #endif |
| OLD | NEW |