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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 }; | 202 }; |
203 | 203 |
204 #endif | 204 #endif |
205 | 205 |
206 static double time(int loops, Benchmark* bench, Target* target) { | 206 static double time(int loops, Benchmark* bench, Target* target) { |
207 SkCanvas* canvas = target->getCanvas(); | 207 SkCanvas* canvas = target->getCanvas(); |
208 if (canvas) { | 208 if (canvas) { |
209 canvas->clear(SK_ColorWHITE); | 209 canvas->clear(SK_ColorWHITE); |
210 } | 210 } |
| 211 bench->perCanvasLastCallBeforeDraw(canvas); |
211 WallTimer timer; | 212 WallTimer timer; |
212 timer.start(); | 213 timer.start(); |
213 canvas = target->beginTiming(canvas); | 214 canvas = target->beginTiming(canvas); |
214 bench->draw(loops, canvas); | 215 bench->draw(loops, canvas); |
215 if (canvas) { | 216 if (canvas) { |
216 canvas->flush(); | 217 canvas->flush(); |
217 } | 218 } |
218 target->endTiming(); | 219 target->endTiming(); |
219 timer.end(); | 220 timer.end(); |
| 221 bench->perCanvasFirstCallAfterDraw(canvas); |
220 return timer.fWall; | 222 return timer.fWall; |
221 } | 223 } |
222 | 224 |
223 static double estimate_timer_overhead() { | 225 static double estimate_timer_overhead() { |
224 double overhead = 0; | 226 double overhead = 0; |
225 for (int i = 0; i < FLAGS_overheadLoops; i++) { | 227 for (int i = 0; i < FLAGS_overheadLoops; i++) { |
226 WallTimer timer; | 228 WallTimer timer; |
227 timer.start(); | 229 timer.start(); |
228 timer.end(); | 230 timer.end(); |
229 overhead += timer.fWall; | 231 overhead += timer.fWall; |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 | 1295 |
1294 return 0; | 1296 return 0; |
1295 } | 1297 } |
1296 | 1298 |
1297 #if !defined SK_BUILD_FOR_IOS | 1299 #if !defined SK_BUILD_FOR_IOS |
1298 int main(int argc, char** argv) { | 1300 int main(int argc, char** argv) { |
1299 SkCommandLineFlags::Parse(argc, argv); | 1301 SkCommandLineFlags::Parse(argc, argv); |
1300 return nanobench_main(); | 1302 return nanobench_main(); |
1301 } | 1303 } |
1302 #endif | 1304 #endif |
OLD | NEW |