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

Unified Diff: bench/ImageCacheBench.cpp

Issue 507483002: retool image cache to be generic cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase + add comment in unlock Created 6 years, 4 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 | « no previous file | src/core/SkBitmapCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ImageCacheBench.cpp
diff --git a/bench/ImageCacheBench.cpp b/bench/ImageCacheBench.cpp
index 07f332baa22d5cb5e923ac625ce086a9e0c158fc..f4d88da0424d75a0c11f9f9495ee63f8dbbde59d 100644
--- a/bench/ImageCacheBench.cpp
+++ b/bench/ImageCacheBench.cpp
@@ -19,6 +19,15 @@ public:
this->init(sizeof(fPtr) + sizeof(fValue));
}
};
+struct TestRec : public SkScaledImageCache::Rec {
+ TestKey fKey;
+ intptr_t fValue;
+
+ TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {}
+
+ virtual const Key& getKey() const SK_OVERRIDE { return fKey; }
+ virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(fValue); }
+};
}
class ImageCacheBench : public Benchmark {
@@ -36,10 +45,7 @@ public:
void populateCache() {
for (int i = 0; i < CACHE_COUNT; ++i) {
- TestKey key(i);
- SkBitmap tmp;
- tmp.allocN32Pixels(1, 1);
- fCache.unlock(fCache.addAndLock(key, tmp));
+ fCache.unlock(fCache.addAndLock(SkNEW_ARGS(TestRec, (TestKey(i), i))));
}
}
@@ -54,10 +60,9 @@ protected:
}
TestKey key(-1);
- SkBitmap tmp;
- // search for a miss (-1 scale)
+ // search for a miss (-1)
for (int i = 0; i < loops; ++i) {
- SkDEBUGCODE(SkScaledImageCache::ID* id =) fCache.findAndLock(key, &tmp);
+ SkDEBUGCODE(SkScaledImageCache::ID id =) fCache.findAndLock(key);
SkASSERT(NULL == id);
}
}
« no previous file with comments | « no previous file | src/core/SkBitmapCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698