OLD | NEW |
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 "BenchTimer.h" | 8 #include "BenchTimer.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); | 26 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); |
27 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); | 27 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); |
28 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); | 28 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); |
29 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); | 29 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); |
30 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); | 30 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); |
31 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); | 31 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); |
32 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); | 32 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); |
33 DEFINE_bool(skr, false, "Record SKR instead of SKP."); | 33 DEFINE_bool(skr, false, "Record SKR instead of SKP."); |
34 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); | 34 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); |
| 35 DEFINE_string(timescale, "us", "Print times in ms, us, or ns"); |
| 36 |
| 37 static double scale_time(double ms) { |
| 38 if (FLAGS_timescale.contains("us")) ms *= 1000; |
| 39 if (FLAGS_timescale.contains("ns")) ms *= 1000000; |
| 40 return ms; |
| 41 } |
35 | 42 |
36 static SkBBHFactory* parse_FLAGS_bbh() { | 43 static SkBBHFactory* parse_FLAGS_bbh() { |
37 if (FLAGS_bbh.isEmpty()) { | 44 if (FLAGS_bbh.isEmpty()) { |
38 return NULL; | 45 return NULL; |
39 } | 46 } |
40 | 47 |
41 if (FLAGS_bbh.contains("rtree")) { | 48 if (FLAGS_bbh.contains("rtree")) { |
42 return SkNEW(SkRTreeFactory); | 49 return SkNEW(SkRTreeFactory); |
43 } | 50 } |
44 if (FLAGS_bbh.contains("tilegrid")) { | 51 if (FLAGS_bbh.contains("tilegrid")) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 src->draw(canvas); | 83 src->draw(canvas); |
77 } | 84 } |
78 if (FLAGS_endRecording) { | 85 if (FLAGS_endRecording) { |
79 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); | 86 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); |
80 } | 87 } |
81 } | 88 } |
82 } | 89 } |
83 timer.end(); | 90 timer.end(); |
84 | 91 |
85 const double msPerLoop = timer.fCpu / (double)FLAGS_loops; | 92 const double msPerLoop = timer.fCpu / (double)FLAGS_loops; |
86 printf("%u\t%s\n", unsigned(1000 * msPerLoop), name); | 93 printf("%f\t%s\n", scale_time(msPerLoop), name); |
87 } | 94 } |
88 | 95 |
89 int tool_main(int argc, char** argv); | 96 int tool_main(int argc, char** argv); |
90 int tool_main(int argc, char** argv) { | 97 int tool_main(int argc, char** argv) { |
91 SkCommandLineFlags::Parse(argc, argv); | 98 SkCommandLineFlags::Parse(argc, argv); |
92 SkAutoGraphics autoGraphics; | 99 SkAutoGraphics autoGraphics; |
93 | 100 |
94 if (FLAGS_bbh.count() > 1) { | 101 if (FLAGS_bbh.count() > 1) { |
95 SkDebugf("Multiple bbh arguments supplied.\n"); | 102 SkDebugf("Multiple bbh arguments supplied.\n"); |
96 return 1; | 103 return 1; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 bench_record(src, filename.c_str(), bbhFactory.get()); | 135 bench_record(src, filename.c_str(), bbhFactory.get()); |
129 } | 136 } |
130 return failed ? 1 : 0; | 137 return failed ? 1 : 0; |
131 } | 138 } |
132 | 139 |
133 #if !defined SK_BUILD_FOR_IOS | 140 #if !defined SK_BUILD_FOR_IOS |
134 int main(int argc, char * const argv[]) { | 141 int main(int argc, char * const argv[]) { |
135 return tool_main(argc, (char**) argv); | 142 return tool_main(argc, (char**) argv); |
136 } | 143 } |
137 #endif | 144 #endif |
OLD | NEW |