OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Timer.h" |
9 #include "Benchmark.h" | 9 #include "Benchmark.h" |
10 #include "LazyDecodeBitmap.h" | 10 #include "LazyDecodeBitmap.h" |
11 #include "PictureBenchmark.h" | 11 #include "PictureBenchmark.h" |
12 #include "PictureRenderer.h" | 12 #include "PictureRenderer.h" |
13 #include "SkCommandLineFlags.h" | 13 #include "SkCommandLineFlags.h" |
14 #include "SkForceLinking.h" | 14 #include "SkForceLinking.h" |
15 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 #include "SkTArray.h" | 18 #include "SkTArray.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 * To measure recording, use a RecordPictureRenderer. | 57 * To measure recording, use a RecordPictureRenderer. |
58 * @param bBoxType The bounding box hierarchy type to use. | 58 * @param bBoxType The bounding box hierarchy type to use. |
59 * @param pic The picture to draw to the renderer. | 59 * @param pic The picture to draw to the renderer. |
60 * @param numRepeats The number of times to repeat the draw. | 60 * @param numRepeats The number of times to repeat the draw. |
61 * @param timer The timer used to benchmark the work. | 61 * @param timer The timer used to benchmark the work. |
62 */ | 62 */ |
63 static void do_benchmark_work(sk_tools::PictureRenderer* renderer, | 63 static void do_benchmark_work(sk_tools::PictureRenderer* renderer, |
64 BBoxType bBoxType, | 64 BBoxType bBoxType, |
65 SkPicture* pic, | 65 SkPicture* pic, |
66 const int numRepeats, | 66 const int numRepeats, |
67 BenchTimer* timer) { | 67 Timer* timer) { |
68 renderer->setBBoxHierarchyType(bBoxType); | 68 renderer->setBBoxHierarchyType(bBoxType); |
69 renderer->setGridSize(FLAGS_tilesize, FLAGS_tilesize); | 69 renderer->setGridSize(FLAGS_tilesize, FLAGS_tilesize); |
70 renderer->init(pic, NULL, NULL, NULL, false); | 70 renderer->init(pic, NULL, NULL, NULL, false); |
71 | 71 |
72 SkDebugf("%s %d times...\n", renderer->getConfigName().c_str(), numRepeats); | 72 SkDebugf("%s %d times...\n", renderer->getConfigName().c_str(), numRepeats); |
73 for (int i = 0; i < numRepeats; ++i) { | 73 for (int i = 0; i < numRepeats; ++i) { |
74 renderer->setup(); | 74 renderer->setup(); |
75 // Render once to fill caches | 75 // Render once to fill caches |
76 renderer->render(); | 76 renderer->render(); |
77 // Render again to measure | 77 // Render again to measure |
(...skipping 21 matching lines...) Expand all Loading... |
99 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path); | 99 SkDebugf("Couldn't create picture. Ignoring path: %s\n", path); |
100 continue; | 100 continue; |
101 } | 101 } |
102 SkDebugf("Benchmarking path: %s\n", path); | 102 SkDebugf("Benchmarking path: %s\n", path); |
103 Measurement& measurement = measurements.push_back(); | 103 Measurement& measurement = measurements.push_back(); |
104 measurement.fName = path; | 104 measurement.fName = path; |
105 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { | 105 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { |
106 if (!includeBBoxType[bBoxType]) { continue; } | 106 if (!includeBBoxType[bBoxType]) { continue; } |
107 if (FLAGS_playback > 0) { | 107 if (FLAGS_playback > 0) { |
108 sk_tools::TiledPictureRenderer playbackRenderer; | 108 sk_tools::TiledPictureRenderer playbackRenderer; |
109 BenchTimer playbackTimer; | 109 Timer playbackTimer; |
110 do_benchmark_work(&playbackRenderer, (BBoxType)bBoxType, | 110 do_benchmark_work(&playbackRenderer, (BBoxType)bBoxType, |
111 picture, FLAGS_playback, &playbackTimer); | 111 picture, FLAGS_playback, &playbackTimer); |
112 measurement.fPlaybackAverage[bBoxType] = playbackTimer.fCpu; | 112 measurement.fPlaybackAverage[bBoxType] = playbackTimer.fCpu; |
113 } | 113 } |
114 if (FLAGS_record > 0) { | 114 if (FLAGS_record > 0) { |
115 sk_tools::RecordPictureRenderer recordRenderer; | 115 sk_tools::RecordPictureRenderer recordRenderer; |
116 BenchTimer recordTimer; | 116 Timer recordTimer; |
117 do_benchmark_work(&recordRenderer, (BBoxType)bBoxType, | 117 do_benchmark_work(&recordRenderer, (BBoxType)bBoxType, |
118 picture, FLAGS_record, &recordTimer); | 118 picture, FLAGS_record, &recordTimer); |
119 measurement.fRecordAverage[bBoxType] = recordTimer.fCpu; | 119 measurement.fRecordAverage[bBoxType] = recordTimer.fCpu; |
120 } | 120 } |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 Measurement globalMeasurement; | 124 Measurement globalMeasurement; |
125 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { | 125 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { |
126 if (!includeBBoxType[bBoxType]) { continue; } | 126 if (!includeBBoxType[bBoxType]) { continue; } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 185 } |
186 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); | 186 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); |
187 return 0; | 187 return 0; |
188 } | 188 } |
189 | 189 |
190 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 190 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
191 int main(int argc, char** argv) { | 191 int main(int argc, char** argv) { |
192 return tool_main(argc, argv); | 192 return tool_main(argc, argv); |
193 } | 193 } |
194 #endif | 194 #endif |
OLD | NEW |