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

Side by Side Diff: bench/ImageCacheBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « bench/HairlinePathBench.cpp ('k') | bench/ImageDecodeBench.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 "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 10
11 class ImageCacheBench : public SkBenchmark { 11 class ImageCacheBench : public SkBenchmark {
12 SkScaledImageCache fCache; 12 SkScaledImageCache fCache;
13 SkBitmap fBM; 13 SkBitmap fBM;
14 14
15 enum { 15 enum {
16 N = SkBENCHLOOP(1000),
17 DIM = 1, 16 DIM = 1,
18 CACHE_COUNT = 500 17 CACHE_COUNT = 500
19 }; 18 };
20 public: 19 public:
21 ImageCacheBench(void* param) : INHERITED(param) , fCache(CACHE_COUNT * 100) { 20 ImageCacheBench(void* param) : INHERITED(param) , fCache(CACHE_COUNT * 100) {
22 fBM.setConfig(SkBitmap::kARGB_8888_Config, DIM, DIM); 21 fBM.setConfig(SkBitmap::kARGB_8888_Config, DIM, DIM);
23 fBM.allocPixels(); 22 fBM.allocPixels();
24 } 23 }
25 24
26 void populateCache() { 25 void populateCache() {
(...skipping 12 matching lines...) Expand all
39 return "imagecache"; 38 return "imagecache";
40 } 39 }
41 40
42 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 41 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
43 if (fCache.getBytesUsed() == 0) { 42 if (fCache.getBytesUsed() == 0) {
44 this->populateCache(); 43 this->populateCache();
45 } 44 }
46 45
47 SkBitmap tmp; 46 SkBitmap tmp;
48 // search for a miss (-1 scale) 47 // search for a miss (-1 scale)
49 for (int i = 0; i < N; ++i) { 48 for (int i = 0; i < this->getLoops(); ++i) {
50 (void)fCache.findAndLock(fBM, -1, -1, &tmp); 49 (void)fCache.findAndLock(fBM, -1, -1, &tmp);
51 } 50 }
52 } 51 }
53 52
54 private: 53 private:
55 typedef SkBenchmark INHERITED; 54 typedef SkBenchmark INHERITED;
56 }; 55 };
57 56
58 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
59 58
60 DEF_BENCH( return new ImageCacheBench(p); ) 59 DEF_BENCH( return new ImageCacheBench(p); )
OLDNEW
« no previous file with comments | « bench/HairlinePathBench.cpp ('k') | bench/ImageDecodeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698