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 <ctype.h> | 8 #include <ctype.h> |
9 | 9 |
10 #include "nanobench.h" | 10 #include "nanobench.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 }; | 201 }; |
202 | 202 |
203 #endif | 203 #endif |
204 | 204 |
205 static double time(int loops, Benchmark* bench, Target* target) { | 205 static double time(int loops, Benchmark* bench, Target* target) { |
206 SkCanvas* canvas = target->getCanvas(); | 206 SkCanvas* canvas = target->getCanvas(); |
207 if (canvas) { | 207 if (canvas) { |
208 canvas->clear(SK_ColorWHITE); | 208 canvas->clear(SK_ColorWHITE); |
209 } | 209 } |
| 210 bench->preDraw(canvas); |
210 WallTimer timer; | 211 WallTimer timer; |
211 timer.start(); | 212 timer.start(); |
212 canvas = target->beginTiming(canvas); | 213 canvas = target->beginTiming(canvas); |
213 bench->draw(loops, canvas); | 214 bench->draw(loops, canvas); |
214 if (canvas) { | 215 if (canvas) { |
215 canvas->flush(); | 216 canvas->flush(); |
216 } | 217 } |
217 target->endTiming(); | 218 target->endTiming(); |
218 timer.end(); | 219 timer.end(); |
| 220 bench->postDraw(canvas); |
219 return timer.fWall; | 221 return timer.fWall; |
220 } | 222 } |
221 | 223 |
222 static double estimate_timer_overhead() { | 224 static double estimate_timer_overhead() { |
223 double overhead = 0; | 225 double overhead = 0; |
224 for (int i = 0; i < FLAGS_overheadLoops; i++) { | 226 for (int i = 0; i < FLAGS_overheadLoops; i++) { |
225 WallTimer timer; | 227 WallTimer timer; |
226 timer.start(); | 228 timer.start(); |
227 timer.end(); | 229 timer.end(); |
228 overhead += timer.fWall; | 230 overhead += timer.fWall; |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 int runs = 0; | 1159 int runs = 0; |
1158 BenchmarkStream benchStream; | 1160 BenchmarkStream benchStream; |
1159 while (Benchmark* b = benchStream.next()) { | 1161 while (Benchmark* b = benchStream.next()) { |
1160 SkAutoTDelete<Benchmark> bench(b); | 1162 SkAutoTDelete<Benchmark> bench(b); |
1161 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()))
{ | 1163 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()))
{ |
1162 continue; | 1164 continue; |
1163 } | 1165 } |
1164 | 1166 |
1165 if (!configs.isEmpty()) { | 1167 if (!configs.isEmpty()) { |
1166 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi
ze().fY); | 1168 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi
ze().fY); |
1167 bench->preDraw(); | 1169 bench->delayedSetup(); |
1168 } | 1170 } |
1169 for (int i = 0; i < configs.count(); ++i) { | 1171 for (int i = 0; i < configs.count(); ++i) { |
1170 Target* target = is_enabled(b, configs[i]); | 1172 Target* target = is_enabled(b, configs[i]); |
1171 if (!target) { | 1173 if (!target) { |
1172 continue; | 1174 continue; |
1173 } | 1175 } |
1174 | 1176 |
1175 // During HWUI output this canvas may be nullptr. | 1177 // During HWUI output this canvas may be nullptr. |
1176 SkCanvas* canvas = target->getCanvas(); | 1178 SkCanvas* canvas = target->getCanvas(); |
1177 const char* config = target->config.name; | 1179 const char* config = target->config.name; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 | 1292 |
1291 return 0; | 1293 return 0; |
1292 } | 1294 } |
1293 | 1295 |
1294 #if !defined SK_BUILD_FOR_IOS | 1296 #if !defined SK_BUILD_FOR_IOS |
1295 int main(int argc, char** argv) { | 1297 int main(int argc, char** argv) { |
1296 SkCommandLineFlags::Parse(argc, argv); | 1298 SkCommandLineFlags::Parse(argc, argv); |
1297 return nanobench_main(); | 1299 return nanobench_main(); |
1298 } | 1300 } |
1299 #endif | 1301 #endif |
OLD | NEW |