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 "nanobench.h" | 10 #include "nanobench.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "SkData.h" | 31 #include "SkData.h" |
32 #include "SkForceLinking.h" | 32 #include "SkForceLinking.h" |
33 #include "SkGraphics.h" | 33 #include "SkGraphics.h" |
34 #include "SkOSFile.h" | 34 #include "SkOSFile.h" |
35 #include "SkPictureRecorder.h" | 35 #include "SkPictureRecorder.h" |
36 #include "SkPictureUtils.h" | 36 #include "SkPictureUtils.h" |
37 #include "SkString.h" | 37 #include "SkString.h" |
38 #include "SkSurface.h" | 38 #include "SkSurface.h" |
39 #include "SkTaskGroup.h" | 39 #include "SkTaskGroup.h" |
40 #include "SkThreadUtils.h" | 40 #include "SkThreadUtils.h" |
| 41 #include "ThermalManager.h" |
41 | 42 |
42 #include <stdlib.h> | 43 #include <stdlib.h> |
43 | 44 |
44 #ifndef SK_BUILD_FOR_WIN32 | 45 #ifndef SK_BUILD_FOR_WIN32 |
45 #include <unistd.h> | 46 #include <unistd.h> |
46 #endif | 47 #endif |
47 | 48 |
48 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 49 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
49 #include "nanobenchAndroid.h" | 50 #include "nanobenchAndroid.h" |
50 #endif | 51 #endif |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " | 105 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " |
105 "function that ping-pongs between 1.0 and zoomMax."
); | 106 "function that ping-pongs between 1.0 and zoomMax."
); |
106 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 107 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
107 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 108 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
108 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 109 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
109 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 110 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
110 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 111 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
111 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 112 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
112 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; | 113 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; |
113 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); | 114 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); |
| 115 DEFINE_bool(useThermalManager, false, "Uses a thermal manager to prevent overhea
ting\n"); |
114 | 116 |
115 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } | 117 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
116 | 118 |
117 static SkString humanize(double ms) { | 119 static SkString humanize(double ms) { |
118 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 120 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
119 return HumanizeMs(ms); | 121 return HumanizeMs(ms); |
120 } | 122 } |
121 #define HUMANIZE(ms) humanize(ms).c_str() | 123 #define HUMANIZE(ms) humanize(ms).c_str() |
122 | 124 |
123 bool Target::init(SkImageInfo info, Benchmark* bench) { | 125 bool Target::init(SkImageInfo info, Benchmark* bench) { |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 } else if (FLAGS_ms) { | 1045 } else if (FLAGS_ms) { |
1044 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tc
onfig\tbench\n"); | 1046 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tc
onfig\tbench\n"); |
1045 } else { | 1047 } else { |
1046 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconf
ig\tbench\n", | 1048 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconf
ig\tbench\n", |
1047 FLAGS_samples, "samples"); | 1049 FLAGS_samples, "samples"); |
1048 } | 1050 } |
1049 | 1051 |
1050 SkTArray<Config> configs; | 1052 SkTArray<Config> configs; |
1051 create_configs(&configs); | 1053 create_configs(&configs); |
1052 | 1054 |
| 1055 #if USE_THERMAL_MANAGER |
| 1056 ThermalManager tm; |
| 1057 #endif |
| 1058 |
1053 if (FLAGS_keepAlive) { | 1059 if (FLAGS_keepAlive) { |
1054 start_keepalive(); | 1060 start_keepalive(); |
1055 } | 1061 } |
1056 | 1062 |
1057 int runs = 0; | 1063 int runs = 0; |
1058 BenchmarkStream benchStream; | 1064 BenchmarkStream benchStream; |
1059 while (Benchmark* b = benchStream.next()) { | 1065 while (Benchmark* b = benchStream.next()) { |
1060 SkAutoTDelete<Benchmark> bench(b); | 1066 SkAutoTDelete<Benchmark> bench(b); |
1061 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()))
{ | 1067 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()))
{ |
1062 continue; | 1068 continue; |
1063 } | 1069 } |
1064 | 1070 |
1065 if (!configs.empty()) { | 1071 if (!configs.empty()) { |
1066 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi
ze().fY); | 1072 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi
ze().fY); |
1067 bench->delayedSetup(); | 1073 bench->delayedSetup(); |
1068 } | 1074 } |
1069 for (int i = 0; i < configs.count(); ++i) { | 1075 for (int i = 0; i < configs.count(); ++i) { |
| 1076 #if USE_THERMAL_MANAGER |
| 1077 if (FLAGS_useThermalManager && !tm.coolOffIfNecessary()) { |
| 1078 SkDebugf("Could not cool off, timings will be throttled\n"); |
| 1079 } |
| 1080 #endif |
1070 Target* target = is_enabled(b, configs[i]); | 1081 Target* target = is_enabled(b, configs[i]); |
1071 if (!target) { | 1082 if (!target) { |
1072 continue; | 1083 continue; |
1073 } | 1084 } |
1074 | 1085 |
1075 // During HWUI output this canvas may be nullptr. | 1086 // During HWUI output this canvas may be nullptr. |
1076 SkCanvas* canvas = target->getCanvas(); | 1087 SkCanvas* canvas = target->getCanvas(); |
1077 const char* config = target->config.name.c_str(); | 1088 const char* config = target->config.name.c_str(); |
1078 | 1089 |
1079 if (FLAGS_pre_log) { | 1090 if (FLAGS_pre_log) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 | 1227 |
1217 return 0; | 1228 return 0; |
1218 } | 1229 } |
1219 | 1230 |
1220 #if !defined SK_BUILD_FOR_IOS | 1231 #if !defined SK_BUILD_FOR_IOS |
1221 int main(int argc, char** argv) { | 1232 int main(int argc, char** argv) { |
1222 SkCommandLineFlags::Parse(argc, argv); | 1233 SkCommandLineFlags::Parse(argc, argv); |
1223 return nanobench_main(); | 1234 return nanobench_main(); |
1224 } | 1235 } |
1225 #endif | 1236 #endif |
OLD | NEW |