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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); | 100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
102 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " | 102 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " |
103 "function that ping-pongs between 1.0 and zoomMax."
); | 103 "function that ping-pongs between 1.0 and zoomMax."
); |
104 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 104 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
105 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 105 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
106 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 106 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
107 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 107 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
108 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 108 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
109 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 109 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
| 110 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; |
110 | 111 |
111 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } | 112 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
112 | 113 |
113 static SkString humanize(double ms) { | 114 static SkString humanize(double ms) { |
114 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 115 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
115 return HumanizeMs(ms); | 116 return HumanizeMs(ms); |
116 } | 117 } |
117 #define HUMANIZE(ms) humanize(ms).c_str() | 118 #define HUMANIZE(ms) humanize(ms).c_str() |
118 | 119 |
119 bool Target::init(SkImageInfo info, Benchmark* bench) { | 120 bool Target::init(SkImageInfo info, Benchmark* bench) { |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 do { | 1178 do { |
1178 samples.push_back(time(loops, bench, target) / loops); | 1179 samples.push_back(time(loops, bench, target) / loops); |
1179 } while (now_ms() < stop); | 1180 } while (now_ms() < stop); |
1180 } else { | 1181 } else { |
1181 samples.reset(FLAGS_samples); | 1182 samples.reset(FLAGS_samples); |
1182 for (int s = 0; s < FLAGS_samples; s++) { | 1183 for (int s = 0; s < FLAGS_samples; s++) { |
1183 samples[s] = time(loops, bench, target) / loops; | 1184 samples[s] = time(loops, bench, target) / loops; |
1184 } | 1185 } |
1185 } | 1186 } |
1186 | 1187 |
| 1188 #if SK_SUPPORT_GPU |
| 1189 SkTArray<SkString> keys; |
| 1190 SkTArray<double> values; |
| 1191 bool gpuStatsDump = FLAGS_gpuStatsDump && Benchmark::kGPU_Backend ==
configs[i].backend; |
| 1192 if (gpuStatsDump) { |
| 1193 // TODO cache stats |
| 1194 bench->getGpuStats(canvas, &keys, &values); |
| 1195 } |
| 1196 #endif |
| 1197 |
1187 bench->perCanvasPostDraw(canvas); | 1198 bench->perCanvasPostDraw(canvas); |
1188 | 1199 |
1189 if (Benchmark::kNonRendering_Backend != target->config.backend && | 1200 if (Benchmark::kNonRendering_Backend != target->config.backend && |
1190 !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) { | 1201 !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) { |
1191 SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config
); | 1202 SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config
); |
1192 pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniq
ueName()); | 1203 pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniq
ueName()); |
1193 pngFilename.append(".png"); | 1204 pngFilename.append(".png"); |
1194 write_canvas_png(target, pngFilename); | 1205 write_canvas_png(target, pngFilename); |
1195 } | 1206 } |
1196 | 1207 |
1197 if (kFailedLoops == loops) { | 1208 if (kFailedLoops == loops) { |
1198 // Can't be timed. A warning note has already been printed. | 1209 // Can't be timed. A warning note has already been printed. |
1199 cleanup_run(target); | 1210 cleanup_run(target); |
1200 continue; | 1211 continue; |
1201 } | 1212 } |
1202 | 1213 |
1203 Stats stats(samples); | 1214 Stats stats(samples); |
1204 log->config(config); | 1215 log->config(config); |
1205 log->configOption("name", bench->getName()); | 1216 log->configOption("name", bench->getName()); |
1206 benchStream.fillCurrentOptions(log.get()); | 1217 benchStream.fillCurrentOptions(log.get()); |
1207 target->fillOptions(log.get()); | 1218 target->fillOptions(log.get()); |
1208 log->metric("min_ms", stats.min); | 1219 log->metric("min_ms", stats.min); |
| 1220 #if SK_SUPPORT_GPU |
| 1221 if (gpuStatsDump) { |
| 1222 // dump to json, only SKPBench currently returns valid keys / va
lues |
| 1223 SkASSERT(keys.count() == values.count()); |
| 1224 for (int i = 0; i < keys.count(); i++) { |
| 1225 log->metric(keys[i].c_str(), values[i]); |
| 1226 } |
| 1227 } |
| 1228 #endif |
| 1229 |
1209 if (runs++ % FLAGS_flushEvery == 0) { | 1230 if (runs++ % FLAGS_flushEvery == 0) { |
1210 log->flush(); | 1231 log->flush(); |
1211 } | 1232 } |
1212 | 1233 |
1213 if (kAutoTuneLoops != FLAGS_loops) { | 1234 if (kAutoTuneLoops != FLAGS_loops) { |
1214 if (configs.count() == 1) { | 1235 if (configs.count() == 1) { |
1215 config = ""; // Only print the config if we run the same ben
ch on more than one. | 1236 config = ""; // Only print the config if we run the same ben
ch on more than one. |
1216 } | 1237 } |
1217 SkDebugf("%4d/%-4dMB\t%s\t%s\n" | 1238 SkDebugf("%4d/%-4dMB\t%s\t%s\n" |
1218 , sk_tools::getCurrResidentSetSizeMB() | 1239 , sk_tools::getCurrResidentSetSizeMB() |
(...skipping 14 matching lines...) Expand all Loading... |
1233 , HUMANIZE(stats.min) | 1254 , HUMANIZE(stats.min) |
1234 , HUMANIZE(stats.median) | 1255 , HUMANIZE(stats.median) |
1235 , HUMANIZE(stats.mean) | 1256 , HUMANIZE(stats.mean) |
1236 , HUMANIZE(stats.max) | 1257 , HUMANIZE(stats.max) |
1237 , stddev_percent | 1258 , stddev_percent |
1238 , FLAGS_ms ? to_string(samples.count()).c_str() : stats.
plot.c_str() | 1259 , FLAGS_ms ? to_string(samples.count()).c_str() : stats.
plot.c_str() |
1239 , config | 1260 , config |
1240 , bench->getUniqueName() | 1261 , bench->getUniqueName() |
1241 ); | 1262 ); |
1242 } | 1263 } |
| 1264 |
1243 #if SK_SUPPORT_GPU | 1265 #if SK_SUPPORT_GPU |
1244 if (FLAGS_gpuStats && | 1266 if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend)
{ |
1245 Benchmark::kGPU_Backend == configs[i].backend) { | |
1246 gGrFactory->get(configs[i].ctxType)->printCacheStats(); | 1267 gGrFactory->get(configs[i].ctxType)->printCacheStats(); |
1247 gGrFactory->get(configs[i].ctxType)->printGpuStats(); | 1268 gGrFactory->get(configs[i].ctxType)->printGpuStats(); |
1248 } | 1269 } |
1249 #endif | 1270 #endif |
| 1271 |
1250 if (FLAGS_verbose) { | 1272 if (FLAGS_verbose) { |
1251 SkDebugf("Samples: "); | 1273 SkDebugf("Samples: "); |
1252 for (int i = 0; i < samples.count(); i++) { | 1274 for (int i = 0; i < samples.count(); i++) { |
1253 SkDebugf("%s ", HUMANIZE(samples[i])); | 1275 SkDebugf("%s ", HUMANIZE(samples[i])); |
1254 } | 1276 } |
1255 SkDebugf("%s\n", bench->getUniqueName()); | 1277 SkDebugf("%s\n", bench->getUniqueName()); |
1256 } | 1278 } |
1257 cleanup_run(target); | 1279 cleanup_run(target); |
1258 } | 1280 } |
1259 } | 1281 } |
(...skipping 10 matching lines...) Expand all Loading... |
1270 | 1292 |
1271 return 0; | 1293 return 0; |
1272 } | 1294 } |
1273 | 1295 |
1274 #if !defined SK_BUILD_FOR_IOS | 1296 #if !defined SK_BUILD_FOR_IOS |
1275 int main(int argc, char** argv) { | 1297 int main(int argc, char** argv) { |
1276 SkCommandLineFlags::Parse(argc, argv); | 1298 SkCommandLineFlags::Parse(argc, argv); |
1277 return nanobench_main(); | 1299 return nanobench_main(); |
1278 } | 1300 } |
1279 #endif | 1301 #endif |
OLD | NEW |