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" |
11 #include "PictureRenderer.h" | 11 #include "PictureRenderer.h" |
12 #include "SkBenchmark.h" | 12 #include "SkBenchmark.h" |
13 #include "SkForceLinking.h" | 13 #include "SkForceLinking.h" |
14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
15 #include "SkStream.h" | 15 #include "SkStream.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
| 17 #include "SkTArray.h" |
17 #include "TimerData.h" | 18 #include "TimerData.h" |
18 | 19 |
19 static const int kNumNormalRecordings = SkBENCHLOOP(10); | 20 static const int kNumNormalRecordings = SkBENCHLOOP(10); |
20 static const int kNumRTreeRecordings = SkBENCHLOOP(10); | 21 static const int kNumRTreeRecordings = SkBENCHLOOP(10); |
21 static const int kNumPlaybacks = SkBENCHLOOP(4); | 22 static const int kNumPlaybacks = SkBENCHLOOP(4); |
22 static const size_t kNumBaseBenchmarks = 3; | 23 static const size_t kNumBaseBenchmarks = 3; |
23 static const size_t kNumTileSizes = 3; | 24 static const size_t kNumTileSizes = 3; |
24 static const size_t kNumBbhPlaybackBenchmarks = 3; | 25 static const size_t kNumBbhPlaybackBenchmarks = 3; |
25 static const size_t kNumBenchmarks = kNumBaseBenchmarks + kNumBbhPlaybackBenchma
rks; | 26 static const size_t kNumBenchmarks = kNumBaseBenchmarks + kNumBbhPlaybackBenchma
rks; |
26 | 27 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 * Will loop along all skp files and perform measurments. | 259 * Will loop along all skp files and perform measurments. |
259 * | 260 * |
260 * Returns a SkScalar representing CPU time taken during benchmark. | 261 * Returns a SkScalar representing CPU time taken during benchmark. |
261 * As a side effect, it spits the timer result to stdout. | 262 * As a side effect, it spits the timer result to stdout. |
262 * Will return -1.0 on error. | 263 * Will return -1.0 on error. |
263 */ | 264 */ |
264 static bool benchmark_loop( | 265 static bool benchmark_loop( |
265 int argc, | 266 int argc, |
266 char **argv, | 267 char **argv, |
267 const BenchmarkControl& benchControl, | 268 const BenchmarkControl& benchControl, |
268 Histogram** histogram) { | 269 SkTArray<Histogram>& histogram) { |
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 SkTArray<Histogram> histograms[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); | 327 histograms[i].reset(argc - 1); |
328 bool success = benchmark_loop( | 328 bool success = benchmark_loop( |
329 argc, argv, | 329 argc, argv, |
330 BenchmarkControl::Make(i), | 330 BenchmarkControl::Make(i), |
331 &histograms[i]); | 331 histograms[i]); |
332 if (!success) { | 332 if (!success) { |
333 SkDebugf("benchmark_loop failed at index %d", i); | 333 SkDebugf("benchmark_loop failed at index %d", i); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 // Output gnuplot readable histogram data.. | 337 // Output gnuplot readable histogram data.. |
338 const char* pbTitle = "bbh_shootout_playback.dat"; | 338 const char* pbTitle = "bbh_shootout_playback.dat"; |
339 const char* recTitle = "bbh_shootout_record.dat"; | 339 const char* recTitle = "bbh_shootout_record.dat"; |
340 SkFILEWStream playbackOut(pbTitle); | 340 SkFILEWStream playbackOut(pbTitle); |
341 SkFILEWStream recordOut(recTitle); | 341 SkFILEWStream recordOut(recTitle); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); | 378 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); |
379 | 379 |
380 return 0; | 380 return 0; |
381 } | 381 } |
382 | 382 |
383 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 383 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
384 int main(int argc, char** argv) { | 384 int main(int argc, char** argv) { |
385 return tool_main(argc, argv); | 385 return tool_main(argc, argv); |
386 } | 386 } |
387 #endif | 387 #endif |
OLD | NEW |