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 void* fPtr; | |
16 intptr_t fValue; | 15 intptr_t fValue; |
17 | 16 |
18 TestKey(intptr_t value) : fPtr(&gGlobalAddress), fValue(value) { | 17 TestKey(intptr_t value) : fValue(value) { |
19 this->init(sizeof(fPtr) + sizeof(fValue)); | 18 this->init(&gGlobalAddress, sizeof(fValue)); |
20 } | 19 } |
21 }; | 20 }; |
22 struct TestRec : public SkResourceCache::Rec { | 21 struct TestRec : public SkResourceCache::Rec { |
23 TestKey fKey; | 22 TestKey fKey; |
24 intptr_t fValue; | 23 intptr_t fValue; |
25 | 24 |
26 TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {} | 25 TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {} |
27 | 26 |
28 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } | 27 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } |
29 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(
fValue); } | 28 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(
fValue); } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 private: | 69 private: |
71 typedef Benchmark INHERITED; | 70 typedef Benchmark INHERITED; |
72 }; | 71 }; |
73 | 72 |
74 /////////////////////////////////////////////////////////////////////////////// | 73 /////////////////////////////////////////////////////////////////////////////// |
75 | 74 |
76 DEF_BENCH( return new ImageCacheBench(); ) | 75 DEF_BENCH( return new ImageCacheBench(); ) |
OLD | NEW |