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

Unified Diff: tools/bench_pictures_main.cpp

Issue 12378075: Provide an option in bench_pictures to count pixel ram. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use the logger rather than debug statements. 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/SkLruImageCache.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 0c7644f2441613caf6ed2c160de98bf5f67b1556..d027db96333aea524fd6177d9f52873573b6bdde 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -26,6 +26,7 @@
SkBenchLogger gLogger;
// Flags used by this file, in alphabetical order.
+DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp file");
DECLARE_bool(deferImageDecoding);
DEFINE_string(filter, "",
"type:flag : Enable canvas filtering to disable a paint flag, "
@@ -173,6 +174,13 @@ static bool run_single_benchmark(const SkString& inputPath,
return false;
}
+ // Since the old picture has been deleted, all pixels should be cleared.
+ SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
+ if (FLAGS_countRAM) {
+ // Set the limit to zero, so all pixels will be kept
+ gLruImageCache.setImageCacheLimit(0);
+ }
+
bool success = false;
SkPicture* picture;
if (FLAGS_deferImageDecoding) {
@@ -204,11 +212,29 @@ static bool run_single_benchmark(const SkString& inputPath,
int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
SkLazyPixelRef::ResetCacheStats();
- SkDebugf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
+ SkString hitString;
+ hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
+ gLogger.logProgress(hitString);
gTotalCacheHits += cacheHits;
gTotalCacheMisses += cacheMisses;
}
#endif
+ if (FLAGS_countRAM) {
+ SkString ramCount("RAM used for bitmaps: ");
+ size_t bytes = gLruImageCache.getImageCacheUsed();
+ if (bytes > 1024) {
+ size_t kb = bytes / 1024;
+ if (kb > 1024) {
+ size_t mb = kb / 1024;
+ ramCount.appendf("%zi MB\n", mb);
+ } else {
+ ramCount.appendf("%zi KB\n", kb);
+ }
+ } else {
+ ramCount.appendf("%zi bytes\n", bytes);
+ }
+ gLogger.logProgress(ramCount);
+ }
return true;
}
« no previous file with comments | « src/lazy/SkLruImageCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698