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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 src.draw(&recorder); | 33 src.draw(&recorder); |
34 | 34 |
35 SkRecordOptimize(&record); | 35 SkRecordOptimize(&record); |
36 | 36 |
37 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), | 37 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), |
38 src.height(), | 38 src.height(), |
39 scratch, | 39 scratch, |
40 src.width() * si
zeof(SkPMColor))); | 40 src.width() * si
zeof(SkPMColor))); |
41 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA
GS_tile))); | 41 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA
GS_tile))); |
42 | 42 |
43 const SkNSec start = SkTime::GetNSecs(); | 43 const SkMSec start = SkTime::GetMSecs(); |
44 for (int i = 0; i < FLAGS_loops; i++) { | 44 for (int i = 0; i < FLAGS_loops; i++) { |
45 if (FLAGS_skr) { | 45 if (FLAGS_skr) { |
46 SkRecordDraw(record, canvas.get()); | 46 SkRecordDraw(record, canvas.get()); |
47 } else { | 47 } else { |
48 src.draw(canvas.get()); | 48 src.draw(canvas.get()); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 const SkNSec elapsed = SkTime::GetNSecs() - start; | 52 const SkMSec elapsed = SkTime::GetMSecs() - start; |
53 const double nsPerLoop = elapsed / (double)FLAGS_loops; | 53 const double msPerLoop = elapsed / (double)FLAGS_loops; |
54 printf("%u\t%s\n", SkToUInt(nsPerLoop), name); | 54 printf("%6.2f\t%s\n", msPerLoop, name); |
55 } | 55 } |
56 | 56 |
57 int tool_main(int argc, char** argv); | 57 int tool_main(int argc, char** argv); |
58 int tool_main(int argc, char** argv) { | 58 int tool_main(int argc, char** argv) { |
59 SkCommandLineFlags::Parse(argc, argv); | 59 SkCommandLineFlags::Parse(argc, argv); |
60 SkAutoGraphics autoGraphics; | 60 SkAutoGraphics autoGraphics; |
61 | 61 |
62 // We share a single scratch bitmap among benches to reduce the profile nois
e from allocation. | 62 // We share a single scratch bitmap among benches to reduce the profile nois
e from allocation. |
63 static const int kMaxArea = 209825221; // tabl_mozilla is this big. | 63 static const int kMaxArea = 209825221; // tabl_mozilla is this big. |
64 SkAutoTMalloc<SkPMColor> scratch(kMaxArea); | 64 SkAutoTMalloc<SkPMColor> scratch(kMaxArea); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 bench(scratch.get(), *src, filename.c_str()); | 96 bench(scratch.get(), *src, filename.c_str()); |
97 } | 97 } |
98 return failed ? 1 : 0; | 98 return failed ? 1 : 0; |
99 } | 99 } |
100 | 100 |
101 #if !defined SK_BUILD_FOR_IOS | 101 #if !defined SK_BUILD_FOR_IOS |
102 int main(int argc, char * const argv[]) { | 102 int main(int argc, char * const argv[]) { |
103 return tool_main(argc, (char**) argv); | 103 return tool_main(argc, (char**) argv); |
104 } | 104 } |
105 #endif | 105 #endif |
OLD | NEW |