| 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 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 19 matching lines...) Expand all Loading... |
| 314 int tool_main(int argc, char** argv) { | 314 int tool_main(int argc, char** argv) { |
| 315 SkAutoGraphics ag; | 315 SkAutoGraphics ag; |
| 316 SkString usage; | 316 SkString usage; |
| 317 usage.printf("Usage: filename [filename]*\n"); | 317 usage.printf("Usage: filename [filename]*\n"); |
| 318 | 318 |
| 319 if (argc < 2) { | 319 if (argc < 2) { |
| 320 SkDebugf("%s\n", usage.c_str()); | 320 SkDebugf("%s\n", usage.c_str()); |
| 321 return -1; | 321 return -1; |
| 322 } | 322 } |
| 323 | 323 |
| 324 Histogram* histograms[kNumBenchmarks]; | 324 Histogram histograms[argc - 1][kNumBenchmarks]; |
| 325 | 325 |
| 326 for (size_t i = 0; i < kNumBenchmarks; ++i) { | 326 for (size_t i = 0; i < kNumBenchmarks; ++i) { |
| 327 histograms[i] = SkNEW_ARRAY(Histogram, argc - 1); | |
| 328 bool success = benchmark_loop( | 327 bool success = benchmark_loop( |
| 329 argc, argv, | 328 argc, argv, |
| 330 BenchmarkControl::Make(i), | 329 BenchmarkControl::Make(i), |
| 331 &histograms[i]); | 330 histograms[i]); |
| 332 if (!success) { | 331 if (!success) { |
| 333 SkDebugf("benchmark_loop failed at index %d", i); | 332 SkDebugf("benchmark_loop failed at index %d", i); |
| 334 } | 333 } |
| 335 } | 334 } |
| 336 | 335 |
| 337 // Output gnuplot readable histogram data.. | 336 // Output gnuplot readable histogram data.. |
| 338 const char* pbTitle = "bbh_shootout_playback.dat"; | 337 const char* pbTitle = "bbh_shootout_playback.dat"; |
| 339 const char* recTitle = "bbh_shootout_record.dat"; | 338 const char* recTitle = "bbh_shootout_record.dat"; |
| 340 SkFILEWStream playbackOut(pbTitle); | 339 SkFILEWStream playbackOut(pbTitle); |
| 341 SkFILEWStream recordOut(recTitle); | 340 SkFILEWStream recordOut(recTitle); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return 0; | 379 return 0; |
| 381 } | 380 } |
| 382 | 381 |
| 383 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 382 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 384 int main(int argc, char** argv) { | 383 int main(int argc, char** argv) { |
| 385 return tool_main(argc, argv); | 384 return tool_main(argc, argv); |
| 386 } | 385 } |
| 387 #endif | 386 #endif |
| 388 | 387 |
| 389 | 388 |
| OLD | NEW |