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

Side by Side Diff: bench/ImageCacheBench.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « bench/HairlinePathBench.cpp ('k') | bench/ImageFilterCollapse.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 10
11 namespace { 11 namespace {
12 static void* gGlobalAddress; 12 static void* gGlobalAddress;
13 class TestKey : public SkResourceCache::Key { 13 class TestKey : public SkResourceCache::Key {
14 public: 14 public:
15 intptr_t fValue; 15 intptr_t fValue;
16 16
17 TestKey(intptr_t value) : fValue(value) { 17 TestKey(intptr_t value) : fValue(value) {
18 this->init(&gGlobalAddress, 0, sizeof(fValue)); 18 this->init(&gGlobalAddress, 0, sizeof(fValue));
19 } 19 }
20 }; 20 };
21 struct TestRec : public SkResourceCache::Rec { 21 struct TestRec : public SkResourceCache::Rec {
22 TestKey fKey; 22 TestKey fKey;
23 intptr_t fValue; 23 intptr_t fValue;
24 24
25 TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {} 25 TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {}
26 26
27 const Key& getKey() const SK_OVERRIDE { return fKey; } 27 const Key& getKey() const override { return fKey; }
28 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(fValue); } 28 size_t bytesUsed() const override { return sizeof(fKey) + sizeof(fValue); }
29 29
30 static bool Visitor(const SkResourceCache::Rec&, void*) { 30 static bool Visitor(const SkResourceCache::Rec&, void*) {
31 return true; 31 return true;
32 } 32 }
33 }; 33 };
34 } 34 }
35 35
36 class ImageCacheBench : public Benchmark { 36 class ImageCacheBench : public Benchmark {
37 SkResourceCache fCache; 37 SkResourceCache fCache;
38 38
39 enum { 39 enum {
40 CACHE_COUNT = 500 40 CACHE_COUNT = 500
41 }; 41 };
42 public: 42 public:
43 ImageCacheBench() : fCache(CACHE_COUNT * 100) {} 43 ImageCacheBench() : fCache(CACHE_COUNT * 100) {}
44 44
45 void populateCache() { 45 void populateCache() {
46 for (int i = 0; i < CACHE_COUNT; ++i) { 46 for (int i = 0; i < CACHE_COUNT; ++i) {
47 fCache.add(SkNEW_ARGS(TestRec, (TestKey(i), i))); 47 fCache.add(SkNEW_ARGS(TestRec, (TestKey(i), i)));
48 } 48 }
49 } 49 }
50 50
51 protected: 51 protected:
52 const char* onGetName() SK_OVERRIDE { 52 const char* onGetName() override {
53 return "imagecache"; 53 return "imagecache";
54 } 54 }
55 55
56 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 56 void onDraw(const int loops, SkCanvas*) override {
57 if (fCache.getTotalBytesUsed() == 0) { 57 if (fCache.getTotalBytesUsed() == 0) {
58 this->populateCache(); 58 this->populateCache();
59 } 59 }
60 60
61 TestKey key(-1); 61 TestKey key(-1);
62 // search for a miss (-1) 62 // search for a miss (-1)
63 for (int i = 0; i < loops; ++i) { 63 for (int i = 0; i < loops; ++i) {
64 SkDEBUGCODE(bool found =) fCache.find(key, TestRec::Visitor, NULL); 64 SkDEBUGCODE(bool found =) fCache.find(key, TestRec::Visitor, NULL);
65 SkASSERT(!found); 65 SkASSERT(!found);
66 } 66 }
67 } 67 }
68 68
69 private: 69 private:
70 typedef Benchmark INHERITED; 70 typedef Benchmark INHERITED;
71 }; 71 };
72 72
73 /////////////////////////////////////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////////////
74 74
75 DEF_BENCH( return new ImageCacheBench(); ) 75 DEF_BENCH( return new ImageCacheBench(); )
OLDNEW
« no previous file with comments | « bench/HairlinePathBench.cpp ('k') | bench/ImageFilterCollapse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698