Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: tools/bench_pictures_main.cpp

Issue 12393046: Add a way to monitor cache hits and misses for deferred decoding. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lazy/SkLazyPixelRef.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bench_pictures_main.cpp
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index ffcab747720e5e765cab6e06b66b2615c935d715..0c7644f2441613caf6ed2c160de98bf5f67b1556 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -44,6 +44,9 @@ DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual til
"times for drawing the whole page. Requires tiled rendering.");
DEFINE_string(timers, "", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time"
" for each picture.");
+DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecoding and "
+ "LAZY_CACHE_STATS set to true. Report percentage of cache hits when using deferred "
+ "image decoding.");
static char const * const gFilterTypes[] = {
"paint",
@@ -140,6 +143,7 @@ static SkString filterFlagsUsage() {
#include "SkData.h"
#include "SkLruImageCache.h"
+#include "SkLazyPixelRef.h"
static SkLruImageCache gLruImageCache(1024*1024);
@@ -152,6 +156,11 @@ static bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
return factory.installPixelRef(data, bitmap);
}
+#if LAZY_CACHE_STATS
+static int32_t gTotalCacheHits;
+static int32_t gTotalCacheMisses;
+#endif
+
static bool run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
@@ -189,6 +198,18 @@ static bool run_single_benchmark(const SkString& inputPath,
gLogger.logProgress(result);
benchmark.run(picture);
+
+#if LAZY_CACHE_STATS
+ if (FLAGS_trackDeferredCaching) {
+ int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
+ int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
+ SkLazyPixelRef::ResetCacheStats();
+ SkDebugf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
+ gTotalCacheHits += cacheHits;
+ gTotalCacheMisses += cacheMisses;
+ }
+#endif
+
return true;
}
@@ -200,12 +221,12 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
const char* filters = FLAGS_filter[0];
const char* colon = strchr(filters, ':');
if (colon) {
- int type = -1;
+ int32_t type = -1;
size_t typeLen = colon - filters;
for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
if (typeLen == strlen(gFilterTypes[tIndex])
&& !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
- type = tIndex;
+ type = SkToS32(tIndex);
break;
}
}
@@ -396,6 +417,12 @@ int tool_main(int argc, char** argv) {
gLogger.logError(err);
return 1;
}
+#if LAZY_CACHE_STATS
+ if (FLAGS_trackDeferredCaching) {
+ SkDebugf("Total cache hit rate: %f\n",
+ (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
+ }
+#endif
return 0;
}
« no previous file with comments | « src/lazy/SkLazyPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698