| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
| 10 #include "LazyDecodeBitmap.h" | 10 #include "LazyDecodeBitmap.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 DECLARE_int32(multi); | 39 DECLARE_int32(multi); |
| 40 DECLARE_string(readPath); | 40 DECLARE_string(readPath); |
| 41 DEFINE_int32(repeat, 1, "Set the number of times to repeat each test."); | 41 DEFINE_int32(repeat, 1, "Set the number of times to repeat each test."); |
| 42 DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual til
es, rather than " | 42 DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual til
es, rather than " |
| 43 "times for drawing the whole page. Requires tiled rendering."); | 43 "times for drawing the whole page. Requires tiled rendering."); |
| 44 DEFINE_bool(purgeDecodedTex, false, "Purge decoded and GPU-uploaded textures " | 44 DEFINE_bool(purgeDecodedTex, false, "Purge decoded and GPU-uploaded textures " |
| 45 "after each iteration."); | 45 "after each iteration."); |
| 46 DEFINE_string(timers, "c", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or
truncated cpu time" | 46 DEFINE_string(timers, "c", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or
truncated cpu time" |
| 47 " for each picture."); | 47 " for each picture."); |
| 48 DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecod
ing and " | 48 DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecod
ing and " |
| 49 "LAZY_CACHE_STATS set to true. Report percentage of cache hits when
using deferred " | 49 "SK_LAZY_CACHE_STATS set to true. Report percentage of cache hits wh
en using " |
| 50 "image decoding."); | 50 "deferred image decoding."); |
| 51 | 51 |
| 52 static char const * const gFilterTypes[] = { | 52 static char const * const gFilterTypes[] = { |
| 53 "paint", | 53 "paint", |
| 54 "point", | 54 "point", |
| 55 "line", | 55 "line", |
| 56 "bitmap", | 56 "bitmap", |
| 57 "rect", | 57 "rect", |
| 58 "oval", | 58 "oval", |
| 59 "path", | 59 "path", |
| 60 "text", | 60 "text", |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 result += "\n\t\t"; | 135 result += "\n\t\t"; |
| 136 len = result.size(); | 136 len = result.size(); |
| 137 } | 137 } |
| 138 if (index < kFilterFlagsCount - 1) { | 138 if (index < kFilterFlagsCount - 1) { |
| 139 result += " | "; | 139 result += " | "; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 return result; | 142 return result; |
| 143 } | 143 } |
| 144 | 144 |
| 145 #if LAZY_CACHE_STATS | 145 #if SK_LAZY_CACHE_STATS |
| 146 static int32_t gTotalCacheHits; | 146 static int32_t gTotalCacheHits; |
| 147 static int32_t gTotalCacheMisses; | 147 static int32_t gTotalCacheMisses; |
| 148 #endif | 148 #endif |
| 149 | 149 |
| 150 static bool run_single_benchmark(const SkString& inputPath, | 150 static bool run_single_benchmark(const SkString& inputPath, |
| 151 sk_tools::PictureBenchmark& benchmark) { | 151 sk_tools::PictureBenchmark& benchmark) { |
| 152 SkFILEStream inputStream; | 152 SkFILEStream inputStream; |
| 153 | 153 |
| 154 inputStream.setPath(inputPath.c_str()); | 154 inputStream.setPath(inputPath.c_str()); |
| 155 if (!inputStream.isValid()) { | 155 if (!inputStream.isValid()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 185 SkString filename; | 185 SkString filename; |
| 186 sk_tools::get_basename(&filename, inputPath); | 186 sk_tools::get_basename(&filename, inputPath); |
| 187 | 187 |
| 188 SkString result; | 188 SkString result; |
| 189 result.printf("running bench [%i %i] %s ", picture->width(), picture->height
(), | 189 result.printf("running bench [%i %i] %s ", picture->width(), picture->height
(), |
| 190 filename.c_str()); | 190 filename.c_str()); |
| 191 gLogger.logProgress(result); | 191 gLogger.logProgress(result); |
| 192 | 192 |
| 193 benchmark.run(picture); | 193 benchmark.run(picture); |
| 194 | 194 |
| 195 #if LAZY_CACHE_STATS | 195 #if SK_LAZY_CACHE_STATS |
| 196 if (FLAGS_trackDeferredCaching) { | 196 if (FLAGS_trackDeferredCaching) { |
| 197 int32_t cacheHits = pool->fCacheHits; | 197 int cacheHits = pool->getCacheHits(); |
| 198 int32_t cacheMisses = pool->fCacheMisses; | 198 int cacheMisses = pool->getCacheMisses(); |
| 199 pool->fCacheHits = pool->fCacheMisses = 0; | 199 pool->resetCacheHitsAndMisses(); |
| 200 SkString hitString; | 200 SkString hitString; |
| 201 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits
+ cacheMisses)); | 201 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits
+ cacheMisses)); |
| 202 gLogger.logProgress(hitString); | 202 gLogger.logProgress(hitString); |
| 203 gTotalCacheHits += cacheHits; | 203 gTotalCacheHits += cacheHits; |
| 204 gTotalCacheMisses += cacheMisses; | 204 gTotalCacheMisses += cacheMisses; |
| 205 } | 205 } |
| 206 #endif | 206 #endif |
| 207 if (FLAGS_countRAM) { | 207 if (FLAGS_countRAM) { |
| 208 SkString ramCount("RAM used for bitmaps: "); | 208 SkString ramCount("RAM used for bitmaps: "); |
| 209 size_t bytes = pool->getRAMUsed(); | 209 size_t bytes = pool->getRAMUsed(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 for (int i = 0; i < FLAGS_readPath.count(); ++i) { | 428 for (int i = 0; i < FLAGS_readPath.count(); ++i) { |
| 429 failures += process_input(FLAGS_readPath[i], benchmark); | 429 failures += process_input(FLAGS_readPath[i], benchmark); |
| 430 } | 430 } |
| 431 | 431 |
| 432 if (failures != 0) { | 432 if (failures != 0) { |
| 433 SkString err; | 433 SkString err; |
| 434 err.printf("Failed to run %i benchmarks.\n", failures); | 434 err.printf("Failed to run %i benchmarks.\n", failures); |
| 435 gLogger.logError(err); | 435 gLogger.logError(err); |
| 436 return 1; | 436 return 1; |
| 437 } | 437 } |
| 438 #if LAZY_CACHE_STATS | 438 #if SK_LAZY_CACHE_STATS |
| 439 if (FLAGS_trackDeferredCaching) { | 439 if (FLAGS_trackDeferredCaching) { |
| 440 SkDebugf("Total cache hit rate: %f\n", | 440 SkDebugf("Total cache hit rate: %f\n", |
| 441 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses
)); | 441 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses
)); |
| 442 } | 442 } |
| 443 #endif | 443 #endif |
| 444 return 0; | 444 return 0; |
| 445 } | 445 } |
| 446 | 446 |
| 447 #if !defined SK_BUILD_FOR_IOS | 447 #if !defined SK_BUILD_FOR_IOS |
| 448 int main(int argc, char * const argv[]) { | 448 int main(int argc, char * const argv[]) { |
| 449 return tool_main(argc, (char**) argv); | 449 return tool_main(argc, (char**) argv); |
| 450 } | 450 } |
| 451 #endif | 451 #endif |
| OLD | NEW |