| 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 "BenchTimer.h" |
| 9 #include "LazyDecodeBitmap.h" | 9 #include "LazyDecodeBitmap.h" |
| 10 #include "PictureBenchmark.h" | 10 #include "PictureBenchmark.h" |
| 11 #include "PictureRenderer.h" | 11 #include "PictureRenderer.h" |
| 12 #include "SkBenchmark.h" | 12 #include "SkBenchmark.h" |
| 13 #include "SkForceLinking.h" | 13 #include "SkForceLinking.h" |
| 14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
| 15 #include "SkStream.h" | 15 #include "SkStream.h" |
| 16 #include "SkString.h" | 16 #include "SkString.h" |
| 17 #include "SkTArray.h" | 17 #include "SkTArray.h" |
| 18 #include "SkCommandLineFlags.h" | 18 #include "SkCommandLineFlags.h" |
| 19 | 19 |
| 20 typedef sk_tools::PictureRenderer::BBoxHierarchyType BBoxType; | 20 typedef sk_tools::PictureRenderer::BBoxHierarchyType BBoxType; |
| 21 static const int kBBoxTypeCount = sk_tools::PictureRenderer::kLast_BBoxHierarchy
Type + 1; | 21 static const int kBBoxTypeCount = sk_tools::PictureRenderer::kLast_BBoxHierarchy
Type + 1; |
| 22 | 22 |
| 23 | 23 |
| 24 DEFINE_string2(skps, r, "", "The list of SKPs to benchmark."); | 24 DEFINE_string2(skps, r, "", "The list of SKPs to benchmark."); |
| 25 DEFINE_string(bbh, "", "The set of bbox types to test. If empty, all are tested.
" | 25 DEFINE_string(bb_types, "", "The set of bbox types to test. If empty, all are te
sted. " |
| 26 "Should be one or more of none, quadtree, rtree, tilegrid
."); | 26 "Should be one or more of none, quadtree, rtree, tilegrid
."); |
| 27 DEFINE_int32(record, 100, "Number of times to record each SKP."); | 27 DEFINE_int32(record, 100, "Number of times to record each SKP."); |
| 28 DEFINE_int32(playback, 1, "Number of times to playback each SKP."); | 28 DEFINE_int32(playback, 1, "Number of times to playback each SKP."); |
| 29 DEFINE_int32(tilesize, 256, "The size of a tile."); | 29 DEFINE_int32(tilesize, 256, "The size of a tile."); |
| 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 }; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 timer->end(); | 80 timer->end(); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 int tool_main(int argc, char** argv); | 84 int tool_main(int argc, char** argv); |
| 85 int tool_main(int argc, char** argv) { | 85 int tool_main(int argc, char** argv) { |
| 86 SkCommandLineFlags::Parse(argc, argv); | 86 SkCommandLineFlags::Parse(argc, argv); |
| 87 SkAutoGraphics ag; | 87 SkAutoGraphics ag; |
| 88 bool includeBBoxType[kBBoxTypeCount]; | 88 bool includeBBoxType[kBBoxTypeCount]; |
| 89 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { | 89 for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) { |
| 90 includeBBoxType[bBoxType] = (FLAGS_bbh.count() == 0) || | 90 includeBBoxType[bBoxType] = (FLAGS_bb_types.count() == 0) || |
| 91 FLAGS_bbh.contains(kBBoxHierarchyTypeNames[bBoxType]); | 91 FLAGS_bb_types.contains(kBBoxHierarchyTypeNames[bBoxType]); |
| 92 } | 92 } |
| 93 // go through all the pictures | 93 // go through all the pictures |
| 94 SkTArray<Measurement> measurements; | 94 SkTArray<Measurement> measurements; |
| 95 for (int index = 0; index < FLAGS_skps.count(); ++index) { | 95 for (int index = 0; index < FLAGS_skps.count(); ++index) { |
| 96 const char* path = FLAGS_skps[index]; | 96 const char* path = FLAGS_skps[index]; |
| 97 SkPicture* picture = pic_from_path(path); | 97 SkPicture* picture = pic_from_path(path); |
| 98 if (NULL == picture) { | 98 if (NULL == picture) { |
| 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 } |
| (...skipping 83 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 |