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

Side by Side Diff: tools/bench_playback.cpp

Issue 346753003: Revert of Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 | « tools/bench_pictures_main.cpp ('k') | tools/bench_record.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 2014 Google Inc. 2 * Copyright 2014 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 "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
11 #include "SkOSFile.h" 11 #include "SkOSFile.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkPictureRecorder.h" 13 #include "SkPictureRecorder.h"
14 #include "SkStream.h" 14 #include "SkStream.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 16
17 #include "../include/record/SkRecording.h" 17 #include "../include/record/SkRecording.h"
18 18
19 #include "BenchTimer.h"
19 #include "Stats.h" 20 #include "Stats.h"
20 #include "Timer.h" 21
22 typedef WallTimer Timer;
21 23
22 __SK_FORCE_IMAGE_DECODER_LINKING; 24 __SK_FORCE_IMAGE_DECODER_LINKING;
23 25
24 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to playback."); 26 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to playback.");
25 DEFINE_int32(samples, 10, "Gather this many samples of each picture playback."); 27 DEFINE_int32(samples, 10, "Gather this many samples of each picture playback.");
26 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); 28 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture.");
27 DEFINE_int32(tile, 1000000000, "Simulated tile size."); 29 DEFINE_int32(tile, 1000000000, "Simulated tile size.");
28 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); 30 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench.");
29 DEFINE_string(timescale, "ms", "Print times in ms, us, or ns"); 31 DEFINE_string(timescale, "ms", "Print times in ms, us, or ns");
30 DEFINE_int32(verbose, 0, "0: print min sample; " 32 DEFINE_int32(verbose, 0, "0: print min sample; "
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), 72 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(),
71 src.height(), 73 src.height(),
72 scratch, 74 scratch,
73 src.width() * si zeof(SkPMColor))); 75 src.width() * si zeof(SkPMColor)));
74 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile))); 76 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile)));
75 77
76 // Draw once to warm any caches. The first sample otherwise can be very noi sy. 78 // Draw once to warm any caches. The first sample otherwise can be very noi sy.
77 draw(*record, *picture, canvas.get()); 79 draw(*record, *picture, canvas.get());
78 80
79 WallTimer timer; 81 Timer timer;
80 const double scale = timescale();
81 SkAutoTMalloc<double> samples(FLAGS_samples); 82 SkAutoTMalloc<double> samples(FLAGS_samples);
82 for (int i = 0; i < FLAGS_samples; i++) { 83 for (int i = 0; i < FLAGS_samples; i++) {
83 // We assume timer overhead (typically, ~30ns) is insignificant 84 // We assume timer overhead (typically, ~30ns) is insignificant
84 // compared to draw runtime (at least ~100us, usually several ms). 85 // compared to draw runtime (at least ~100us, usually several ms).
85 timer.start(); 86 timer.start(timescale());
86 draw(*record, *picture, canvas.get()); 87 draw(*record, *picture, canvas.get());
87 timer.end(); 88 timer.end();
88 samples[i] = timer.fWall * scale; 89 samples[i] = timer.fWall;
89 } 90 }
90 91
91 Stats stats(samples.get(), FLAGS_samples); 92 Stats stats(samples.get(), FLAGS_samples);
92 if (FLAGS_verbose == 0) { 93 if (FLAGS_verbose == 0) {
93 printf("%g\t%s\n", stats.min, name); 94 printf("%g\t%s\n", stats.min, name);
94 } else if (FLAGS_verbose == 1) { 95 } else if (FLAGS_verbose == 1) {
95 // Get a rough idea of how noisy the measurements were. 96 // Get a rough idea of how noisy the measurements were.
96 const double noisePercent = 100 * sqrt(stats.var) / stats.mean; 97 const double noisePercent = 100 * sqrt(stats.var) / stats.mean;
97 printf("%g\t%g\t%g\t±%.0f%%\t%s\n", stats.min, stats.mean, stats.max, no isePercent, name); 98 printf("%g\t%g\t%g\t±%.0f%%\t%s\n", stats.min, stats.mean, stats.max, no isePercent, name);
98 } else if (FLAGS_verbose == 2) { 99 } else if (FLAGS_verbose == 2) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 bench(scratch.get(), *src, filename.c_str()); 147 bench(scratch.get(), *src, filename.c_str());
147 } 148 }
148 return failed ? 1 : 0; 149 return failed ? 1 : 0;
149 } 150 }
150 151
151 #if !defined SK_BUILD_FOR_IOS 152 #if !defined SK_BUILD_FOR_IOS
152 int main(int argc, char * const argv[]) { 153 int main(int argc, char * const argv[]) {
153 return tool_main(argc, (char**) argv); 154 return tool_main(argc, (char**) argv);
154 } 155 }
155 #endif 156 #endif
OLDNEW
« no previous file with comments | « tools/bench_pictures_main.cpp ('k') | tools/bench_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698