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

Side by Side Diff: tools/bbh_shootout.cpp

Issue 19862002: Do timer allocation and string building outside of bench loops (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: on top of tot Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « tools/PictureBenchmark.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 * Returns a SkScalar representing CPU time taken during benchmark. 261 * Returns a SkScalar representing CPU time taken during benchmark.
262 * As a side effect, it spits the timer result to stdout. 262 * As a side effect, it spits the timer result to stdout.
263 * Will return -1.0 on error. 263 * Will return -1.0 on error.
264 */ 264 */
265 static bool benchmark_loop( 265 static bool benchmark_loop(
266 int argc, 266 int argc,
267 char **argv, 267 char **argv,
268 const BenchmarkControl& benchControl, 268 const BenchmarkControl& benchControl,
269 SkTArray<Histogram>& histogram) { 269 SkTArray<Histogram>& histogram) {
270 static const SkString timeFormat("%f"); 270 static const SkString timeFormat("%f");
271 TimerData timerData(timeFormat, timeFormat); 271 TimerData timerData(argc - 1);
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 SkAssertResult(timerData.appendTimes(&timer));
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 /*doubleFormat = */ timeFormat.c_str(),
289 /*printMin = */ false, 289 /*result = */ TimerData::kAvg_Result,
290 /*repeatDraw = */ 1,
291 /*configName = */ benchControl.fName.c_str(), 290 /*configName = */ benchControl.fName.c_str(),
292 /*showWallTime = */ false, 291 /*timerFlags = */ TimerData::kCpu_Flag);
293 /*showTruncatedWallTime = */ false,
294 /*showCpuTime = */ true,
295 /*showTruncatedCpuTime = */ false,
296 /*showGpuTime = */ false);
297 292
298 const char findStr[] = "= "; 293 const char findStr[] = "= ";
299 int pos = timerResult.find(findStr); 294 int pos = timerResult.find(findStr);
300 if (-1 == pos) { 295 if (-1 == pos) {
301 SkDebugf("Unexpected output from TimerData::getResult(...). Unable to pa rse."); 296 SkDebugf("Unexpected output from TimerData::getResult(...). Unable to pa rse.");
302 return false; 297 return false;
303 } 298 }
304 299
305 SkScalar cpuTime = SkDoubleToScalar(atof(timerResult.c_str() + pos + sizeof( findStr) - 1)); 300 SkScalar cpuTime = SkDoubleToScalar(atof(timerResult.c_str() + pos + sizeof( findStr) - 1));
306 if (cpuTime == 0) { // atof returns 0.0 on error. 301 if (cpuTime == 0) { // atof returns 0.0 on error.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e); 373 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e);
379 374
380 return 0; 375 return 0;
381 } 376 }
382 377
383 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 378 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
384 int main(int argc, char** argv) { 379 int main(int argc, char** argv) {
385 return tool_main(argc, argv); 380 return tool_main(argc, argv);
386 } 381 }
387 #endif 382 #endif
OLDNEW
« no previous file with comments | « tools/PictureBenchmark.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698