| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "LazyDecodeBitmap.h" | 9 #include "LazyDecodeBitmap.h" |
| 10 #include "PictureBenchmark.h" | 10 #include "PictureBenchmark.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 * Will loop along all skp files and perform measurments. | 258 * Will loop along all skp files and perform measurments. |
| 259 * | 259 * |
| 260 * Returns a SkScalar representing CPU time taken during benchmark. | 260 * Returns a SkScalar representing CPU time taken during benchmark. |
| 261 * As a side effect, it spits the timer result to stdout. | 261 * As a side effect, it spits the timer result to stdout. |
| 262 * Will return -1.0 on error. | 262 * Will return -1.0 on error. |
| 263 */ | 263 */ |
| 264 static bool benchmark_loop( | 264 static bool benchmark_loop( |
| 265 int argc, | 265 int argc, |
| 266 char **argv, | 266 char **argv, |
| 267 const BenchmarkControl& benchControl, | 267 const BenchmarkControl& benchControl, |
| 268 SkTArray<Histogram>& histogram) { | 268 Histogram** histogram) { |
| 269 | 269 |
| 270 static const SkString timeFormat("%f"); | 270 static const SkString timeFormat("%f"); |
| 271 TimerData timerData(timeFormat, timeFormat); | 271 TimerData timerData(timeFormat, timeFormat); |
| 272 for (int index = 1; index < argc; ++index) { | 272 for (int index = 1; index < argc; ++index) { |
| 273 BenchTimer timer; | 273 BenchTimer timer; |
| 274 SkString path(argv[index]); | 274 SkString path(argv[index]); |
| 275 SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str())); | 275 SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str())); |
| 276 if (NULL == pic) { | 276 if (NULL == pic) { |
| 277 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str(
)); | 277 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str(
)); |
| 278 continue; | 278 continue; |
| 279 } | 279 } |
| 280 benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path,
pic, &timer); | 280 benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path,
pic, &timer); |
| 281 timerData.appendTimes(&timer, argc - 1 == index); | 281 timerData.appendTimes(&timer, argc - 1 == index); |
| 282 | 282 |
| 283 histogram[index - 1].fPath = path; | 283 histogram[index - 1]->fPath = path; |
| 284 histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu); | 284 histogram[index - 1]->fCpuTime = SkDoubleToScalar(timer.fCpu); |
| 285 } | 285 } |
| 286 | 286 |
| 287 const SkString timerResult = timerData.getResult( | 287 const SkString timerResult = timerData.getResult( |
| 288 /*logPerIter = */ false, | 288 /*logPerIter = */ false, |
| 289 /*printMin = */ false, | 289 /*printMin = */ false, |
| 290 /*repeatDraw = */ 1, | 290 /*repeatDraw = */ 1, |
| 291 /*configName = */ benchControl.fName.c_str(), | 291 /*configName = */ benchControl.fName.c_str(), |
| 292 /*showWallTime = */ false, | 292 /*showWallTime = */ false, |
| 293 /*showTruncatedWallTime = */ false, | 293 /*showTruncatedWallTime = */ false, |
| 294 /*showCpuTime = */ true, | 294 /*showCpuTime = */ true, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 313 static int tool_main(int argc, char** argv) { | 313 static int tool_main(int argc, char** argv) { |
| 314 SkAutoGraphics ag; | 314 SkAutoGraphics ag; |
| 315 SkString usage; | 315 SkString usage; |
| 316 usage.printf("Usage: filename [filename]*\n"); | 316 usage.printf("Usage: filename [filename]*\n"); |
| 317 | 317 |
| 318 if (argc < 2) { | 318 if (argc < 2) { |
| 319 SkDebugf("%s\n", usage.c_str()); | 319 SkDebugf("%s\n", usage.c_str()); |
| 320 return -1; | 320 return -1; |
| 321 } | 321 } |
| 322 | 322 |
| 323 static SkTArray<Histogram> histograms[kNumBenchmarks]; | 323 Histogram* histograms[kNumBenchmarks]; |
| 324 | 324 |
| 325 for (size_t i = 0; i < kNumBenchmarks; ++i) { | 325 for (size_t i = 0; i < kNumBenchmarks; ++i) { |
| 326 histograms[i].reset(argc - 1); | 326 histograms[i] = SkNEW_ARRAY(Histogram, argc - 1); |
| 327 bool success = benchmark_loop( | 327 bool success = benchmark_loop( |
| 328 argc, argv, | 328 argc, argv, |
| 329 BenchmarkControl::Make(i), | 329 BenchmarkControl::Make(i), |
| 330 histograms[i]); | 330 &histograms[i]); |
| 331 if (!success) { | 331 if (!success) { |
| 332 SkDebugf("benchmark_loop failed at index %d", i); | 332 SkDebugf("benchmark_loop failed at index %d", i); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Output gnuplot readable histogram data.. | 336 // Output gnuplot readable histogram data.. |
| 337 const char* pbTitle = "bbh_shootout_playback.dat"; | 337 const char* pbTitle = "bbh_shootout_playback.dat"; |
| 338 const char* recTitle = "bbh_shootout_record.dat"; | 338 const char* recTitle = "bbh_shootout_record.dat"; |
| 339 SkFILEWStream playbackOut(pbTitle); | 339 SkFILEWStream playbackOut(pbTitle); |
| 340 SkFILEWStream recordOut(recTitle); | 340 SkFILEWStream recordOut(recTitle); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 376 } |
| 377 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); | 377 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); |
| 378 | 378 |
| 379 return 0; | 379 return 0; |
| 380 } | 380 } |
| 381 | 381 |
| 382 int main(int argc, char** argv) { | 382 int main(int argc, char** argv) { |
| 383 return tool_main(argc, argv); | 383 return tool_main(argc, argv); |
| 384 } | 384 } |
| 385 | 385 |
| OLD | NEW |