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 "Timer.h" | 8 #include "Timer.h" |
9 #include "Benchmark.h" | 9 #include "Benchmark.h" |
10 #include "LazyDecodeBitmap.h" | 10 #include "LazyDecodeBitmap.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 struct Measurement { | 31 struct Measurement { |
32 SkString fName; | 32 SkString fName; |
33 double fRecordAverage[kBBoxTypeCount]; | 33 double fRecordAverage[kBBoxTypeCount]; |
34 double fPlaybackAverage[kBBoxTypeCount]; | 34 double fPlaybackAverage[kBBoxTypeCount]; |
35 }; | 35 }; |
36 | 36 |
37 const char* kBBoxHierarchyTypeNames[kBBoxTypeCount] = { | 37 const char* kBBoxHierarchyTypeNames[kBBoxTypeCount] = { |
38 "none", // kNone_BBoxHierarchyType | 38 "none", // kNone_BBoxHierarchyType |
39 "rtree", // kRTree_BBoxHierarchyType | 39 "rtree", // kRTree_BBoxHierarchyType |
40 "tilegrid", // kTileGrid_BBoxHierarchyType | |
41 }; | 40 }; |
42 | 41 |
43 static SkPicture* pic_from_path(const char path[]) { | 42 static SkPicture* pic_from_path(const char path[]) { |
44 SkFILEStream stream(path); | 43 SkFILEStream stream(path); |
45 if (!stream.isValid()) { | 44 if (!stream.isValid()) { |
46 SkDebugf("-- Can't open '%s'\n", path); | 45 SkDebugf("-- Can't open '%s'\n", path); |
47 return NULL; | 46 return NULL; |
48 } | 47 } |
49 return SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap); | 48 return SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap); |
50 } | 49 } |
51 | 50 |
52 /** | 51 /** |
53 * This function is the sink to which all work ends up going. | 52 * This function is the sink to which all work ends up going. |
54 * @param renderer The renderer to use to perform the work. | 53 * @param renderer The renderer to use to perform the work. |
55 * To measure rendering, use a TiledPictureRenderer. | 54 * To measure rendering, use a TiledPictureRenderer. |
56 * To measure recording, use a RecordPictureRenderer. | 55 * To measure recording, use a RecordPictureRenderer. |
57 * @param bBoxType The bounding box hierarchy type to use. | 56 * @param bBoxType The bounding box hierarchy type to use. |
58 * @param pic The picture to draw to the renderer. | 57 * @param pic The picture to draw to the renderer. |
59 * @param numRepeats The number of times to repeat the draw. | 58 * @param numRepeats The number of times to repeat the draw. |
60 * @param timer The timer used to benchmark the work. | 59 * @param timer The timer used to benchmark the work. |
61 */ | 60 */ |
62 static void do_benchmark_work(sk_tools::PictureRenderer* renderer, | 61 static void do_benchmark_work(sk_tools::PictureRenderer* renderer, |
63 BBoxType bBoxType, | 62 BBoxType bBoxType, |
64 SkPicture* pic, | 63 SkPicture* pic, |
65 const int numRepeats, | 64 const int numRepeats, |
66 Timer* timer) { | 65 Timer* timer) { |
67 renderer->setBBoxHierarchyType(bBoxType); | 66 renderer->setBBoxHierarchyType(bBoxType); |
68 renderer->setGridSize(FLAGS_tilesize, FLAGS_tilesize); | |
69 renderer->init(pic, NULL, NULL, NULL, false, false); | 67 renderer->init(pic, NULL, NULL, NULL, false, false); |
70 | 68 |
71 SkDebugf("%s %d times...\n", renderer->getConfigName().c_str(), numRepeats); | 69 SkDebugf("%s %d times...\n", renderer->getConfigName().c_str(), numRepeats); |
72 for (int i = 0; i < numRepeats; ++i) { | 70 for (int i = 0; i < numRepeats; ++i) { |
73 renderer->setup(); | 71 renderer->setup(); |
74 // Render once to fill caches | 72 // Render once to fill caches |
75 renderer->render(); | 73 renderer->render(); |
76 // Render again to measure | 74 // Render again to measure |
77 timer->start(); | 75 timer->start(); |
78 renderer->render(); | 76 renderer->render(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 192 } |
195 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); | 193 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl
e); |
196 return 0; | 194 return 0; |
197 } | 195 } |
198 | 196 |
199 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 197 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
200 int main(int argc, char** argv) { | 198 int main(int argc, char** argv) { |
201 return tool_main(argc, argv); | 199 return tool_main(argc, argv); |
202 } | 200 } |
203 #endif | 201 #endif |
OLD | NEW |