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

Side by Side Diff: tools/bench_playback.cpp

Issue 243273002: Add --match to bench tools, extra decimal to bench_pictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 | 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 "SkRecordDraw.h" 13 #include "SkRecordDraw.h"
14 #include "SkRecorder.h" 14 #include "SkRecorder.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 #include "SkTime.h" 17 #include "SkTime.h"
18 18
19 __SK_FORCE_IMAGE_DECODER_LINKING; 19 __SK_FORCE_IMAGE_DECODER_LINKING;
20 20
21 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record ."); 21 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record .");
22 DEFINE_int32(loops, 10, "Number of times to play back each SKP."); 22 DEFINE_int32(loops, 10, "Number of times to play back each SKP.");
23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); 23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture.");
24 DEFINE_int32(tile, 1000000000, "Simulated tile size."); 24 DEFINE_int32(tile, 1000000000, "Simulated tile size.");
25 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench.");
25 26
26 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) { 27 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
27 // We don't use the public SkRecording interface here because we need kWrite Only_Mode. 28 // We don't use the public SkRecording interface here because we need kWrite Only_Mode.
28 // (We don't want SkPicturePlayback to be able to optimize playing into our SkRecord.) 29 // (We don't want SkPicturePlayback to be able to optimize playing into our SkRecord.)
29 SkRecord record; 30 SkRecord record;
30 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h eight()); 31 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h eight());
31 src.draw(&recorder); 32 src.draw(&recorder);
32 33
33 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), 34 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(),
34 src.height(), 35 src.height(),
35 scratch, 36 scratch,
36 src.width() * si zeof(SkPMColor))); 37 src.width() * si zeof(SkPMColor)));
37 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile))); 38 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile)));
38 39
39 const SkMSec start = SkTime::GetMSecs(); 40 const SkMSec start = SkTime::GetMSecs();
40 for (int i = 0; i < FLAGS_loops; i++) { 41 for (int i = 0; i < FLAGS_loops; i++) {
41 if (FLAGS_skr) { 42 if (FLAGS_skr) {
42 SkRecordDraw(record, canvas.get()); 43 SkRecordDraw(record, canvas.get());
43 } else { 44 } else {
44 src.draw(canvas.get()); 45 src.draw(canvas.get());
45 } 46 }
46 } 47 }
47 48
48 const SkMSec elapsed = SkTime::GetMSecs() - start; 49 const SkMSec elapsed = SkTime::GetMSecs() - start;
49 const double msPerLoop = elapsed / (double)FLAGS_loops; 50 const double msPerLoop = elapsed / (double)FLAGS_loops;
50 printf("%5.1f\t%s\n", msPerLoop, name); 51 printf("%6.2f\t%s\n", msPerLoop, name);
51 } 52 }
52 53
53 int tool_main(int argc, char** argv); 54 int tool_main(int argc, char** argv);
54 int tool_main(int argc, char** argv) { 55 int tool_main(int argc, char** argv) {
55 SkCommandLineFlags::Parse(argc, argv); 56 SkCommandLineFlags::Parse(argc, argv);
56 SkAutoGraphics autoGraphics; 57 SkAutoGraphics autoGraphics;
57 58
58 // We share a single scratch bitmap among benches to reduce the profile nois e from allocation. 59 // We share a single scratch bitmap among benches to reduce the profile nois e from allocation.
59 static const int kMaxArea = 209825221; // tabl_mozilla is this big. 60 static const int kMaxArea = 209825221; // tabl_mozilla is this big.
60 SkAutoTMalloc<SkPMColor> scratch(kMaxArea); 61 SkAutoTMalloc<SkPMColor> scratch(kMaxArea);
61 62
62 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); 63 SkOSFile::Iter it(FLAGS_skps[0], ".skp");
63 SkString filename; 64 SkString filename;
64 bool failed = false; 65 bool failed = false;
65 while (it.next(&filename)) { 66 while (it.next(&filename)) {
67 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) {
68 continue;
69 }
70
66 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str ()); 71 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str ());
67 72
68 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); 73 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
69 if (!stream) { 74 if (!stream) {
70 SkDebugf("Could not read %s.\n", path.c_str()); 75 SkDebugf("Could not read %s.\n", path.c_str());
71 failed = true; 76 failed = true;
72 continue; 77 continue;
73 } 78 }
74 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); 79 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
75 if (!src) { 80 if (!src) {
(...skipping 12 matching lines...) Expand all
88 bench(scratch.get(), *src, filename.c_str()); 93 bench(scratch.get(), *src, filename.c_str());
89 } 94 }
90 return failed ? 1 : 0; 95 return failed ? 1 : 0;
91 } 96 }
92 97
93 #if !defined SK_BUILD_FOR_IOS 98 #if !defined SK_BUILD_FOR_IOS
94 int main(int argc, char * const argv[]) { 99 int main(int argc, char * const argv[]) {
95 return tool_main(argc, (char**) argv); 100 return tool_main(argc, (char**) argv);
96 } 101 }
97 #endif 102 #endif
OLDNEW
« no previous file with comments | « no previous file | tools/bench_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698