OLD | NEW |
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 override { return fKey; } | 27 const Key& getKey() const override { return fKey; } |
28 size_t bytesUsed() const override { return sizeof(fKey) + sizeof(fValue); } | 28 size_t bytesUsed() const override { return sizeof(fKey) + sizeof(fValue); } |
| 29 const char* getCategory() const override { return "imagecachebench-test"; } |
| 30 SkDiscardableMemory* diagnostic_only_getDiscardable() const override { retur
n NULL; } |
29 | 31 |
30 static bool Visitor(const SkResourceCache::Rec&, void*) { | 32 static bool Visitor(const SkResourceCache::Rec&, void*) { |
31 return true; | 33 return true; |
32 } | 34 } |
33 }; | 35 }; |
34 } | 36 } |
35 | 37 |
36 class ImageCacheBench : public Benchmark { | 38 class ImageCacheBench : public Benchmark { |
37 SkResourceCache fCache; | 39 SkResourceCache fCache; |
38 | 40 |
(...skipping 27 matching lines...) Expand all Loading... |
66 } | 68 } |
67 } | 69 } |
68 | 70 |
69 private: | 71 private: |
70 typedef Benchmark INHERITED; | 72 typedef Benchmark INHERITED; |
71 }; | 73 }; |
72 | 74 |
73 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
74 | 76 |
75 DEF_BENCH( return new ImageCacheBench(); ) | 77 DEF_BENCH( return new ImageCacheBench(); ) |
OLD | NEW |