Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/bbh_shootout.cpp

Issue 187643002: Remove unused TimerData that generates errors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Mac build fix Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 numRecordings = kNumNormalRecordings; 289 numRecordings = kNumNormalRecordings;
290 break; 290 break;
291 } 291 }
292 do_benchmark_work(&renderer, benchControl.fType, 292 do_benchmark_work(&renderer, benchControl.fType,
293 path, pic, numRecordings, "recording", timer); 293 path, pic, numRecordings, "recording", timer);
294 } 294 }
295 295
296 /** 296 /**
297 * Takes argc,argv along with one of the benchmark functions defined above. 297 * Takes argc,argv along with one of the benchmark functions defined above.
298 * Will loop along all skp files and perform measurments. 298 * Will loop along all skp files and perform measurments.
299 *
300 * Returns a SkScalar representing CPU time taken during benchmark.
301 * As a side effect, it spits the timer result to stdout.
302 * Will return -1.0 on error.
303 */ 299 */
304 static bool benchmark_loop( 300 static void benchmark_loop(
305 int argc, 301 int argc,
306 char **argv, 302 char **argv,
307 const BenchmarkControl& benchControl, 303 const BenchmarkControl& benchControl,
308 SkTArray<Histogram>& histogram) { 304 SkTArray<Histogram>& histogram) {
309 static const SkString timeFormat("%f");
310 TimerData timerData(argc - 1);
311 for (int index = 1; index < argc; ++index) { 305 for (int index = 1; index < argc; ++index) {
312 BenchTimer timer; 306 BenchTimer timer;
313 SkString path(argv[index]); 307 SkString path(argv[index]);
314 SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str())); 308 SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str()));
315 if (NULL == pic) { 309 if (NULL == pic) {
316 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str( )); 310 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str( ));
317 continue; 311 continue;
318 } 312 }
319 benchControl.fFunction(benchControl, path, pic, &timer); 313 benchControl.fFunction(benchControl, path, pic, &timer);
320
321 histogram[index - 1].fPath = path; 314 histogram[index - 1].fPath = path;
322 histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu); 315 histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu);
323 } 316 }
324
325 const SkString timerResult = timerData.getResult(
326 /*doubleFormat = */ timeFormat.c_str(),
327 /*result = */ TimerData::kAvg_Result,
328 /*configName = */ benchControl.fName.c_str(),
329 /*timerFlags = */ TimerData::kCpu_Flag);
330
331 const char findStr[] = "= ";
332 int pos = timerResult.find(findStr);
333 if (-1 == pos) {
334 SkDebugf("Unexpected output from TimerData::getResult(...). Unable to pa rse.\n");
335 return false;
336 }
337
338 SkScalar cpuTime = SkDoubleToScalar(atof(timerResult.c_str() + pos + sizeof( findStr) - 1));
339 if (cpuTime == 0) { // atof returns 0.0 on error.
340 SkDebugf("Unable to read value from timer result.\n");
341 return false;
342 }
343 return true;
344 } 317 }
345 318
346 int tool_main(int argc, char** argv); 319 int tool_main(int argc, char** argv);
347 int tool_main(int argc, char** argv) { 320 int tool_main(int argc, char** argv) {
348 SkAutoGraphics ag; 321 SkAutoGraphics ag;
349 SkString usage; 322 SkString usage;
350 usage.printf("Usage: filename [filename]*\n"); 323 usage.printf("Usage: filename [filename]*\n");
351 324
352 if (argc < 2) { 325 if (argc < 2) {
353 SkDebugf("%s\n", usage.c_str()); 326 SkDebugf("%s\n", usage.c_str());
354 return -1; 327 return -1;
355 } 328 }
356 329
357 SkTArray<Histogram> histograms[kNumBenchmarks]; 330 SkTArray<Histogram> histograms[kNumBenchmarks];
358 331
359 for (size_t i = 0; i < kNumBenchmarks; ++i) { 332 for (size_t i = 0; i < kNumBenchmarks; ++i) {
360 histograms[i].reset(argc - 1); 333 histograms[i].reset(argc - 1);
361 bool success = benchmark_loop( 334 benchmark_loop(argc, argv, BenchmarkControl::Make(i), histograms[i]);
362 argc, argv,
363 BenchmarkControl::Make(i),
364 histograms[i]);
365 if (!success) {
366 SkDebugf("benchmark_loop failed at index %d\n", i);
367 }
368 } 335 }
369 336
370 // Output gnuplot readable histogram data.. 337 // Output gnuplot readable histogram data..
371 const char* pbTitle = "bbh_shootout_playback.dat"; 338 const char* pbTitle = "bbh_shootout_playback.dat";
372 const char* recTitle = "bbh_shootout_record.dat"; 339 const char* recTitle = "bbh_shootout_record.dat";
373 SkFILEWStream playbackOut(pbTitle); 340 SkFILEWStream playbackOut(pbTitle);
374 SkFILEWStream recordOut(recTitle); 341 SkFILEWStream recordOut(recTitle);
375 recordOut.writeText("# "); 342 recordOut.writeText("# ");
376 playbackOut.writeText("# "); 343 playbackOut.writeText("# ");
377 for (size_t i = 0; i < kNumBenchmarks; ++i) { 344 for (size_t i = 0; i < kNumBenchmarks; ++i) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e); 398 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e);
432 399
433 return 0; 400 return 0;
434 } 401 }
435 402
436 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 403 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
437 int main(int argc, char** argv) { 404 int main(int argc, char** argv) {
438 return tool_main(argc, argv); 405 return tool_main(argc, argv);
439 } 406 }
440 #endif 407 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698