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

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: 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
« include/lazy/SkLruImageCache.h ('K') | « 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 ffcab747720e5e765cab6e06b66b2615c935d715..68eb1a6a10c3dba6ef0a4db5a6164b501857c8fa 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, "
@@ -164,6 +165,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.getRamUsed() == 0);
+ if (FLAGS_countRAM) {
+ // Set the budget to zero, so all pixels will be kept
+ gLruImageCache.setBudget(0);
+ }
+
bool success = false;
SkPicture* picture;
if (FLAGS_deferImageDecoding) {
@@ -189,6 +197,23 @@ static bool run_single_benchmark(const SkString& inputPath,
gLogger.logProgress(result);
benchmark.run(picture);
+
+ if (FLAGS_countRAM) {
+ SkDebugf("RAM used for bitmaps: ");
+ size_t bytes = gLruImageCache.getRamUsed();
+ if (bytes > 1024) {
+ size_t kb = bytes / 1024;
+ if (kb > 1024) {
+ size_t mb = kb / 1024;
+ SkDebugf("%i MB\n", mb);
+ } else {
+ SkDebugf("%i KB\n", kb);
+ }
+ } else {
+ SkDebugf("%i bytes\n", bytes);
+ }
+ }
+
return true;
}
« include/lazy/SkLruImageCache.h ('K') | « src/lazy/SkLruImageCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698