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

Side by Side Diff: bench/SkBenchmark.h

Issue 178473006: DM: also run benches once. (Closed) Base URL: https://skia.googlesource.com/skia.git@dm
Patch Set: add note Created 6 years, 10 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/GrMemoryPoolBench.cpp ('k') | bench/SkGMBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef SkBenchmark_DEFINED 8 #ifndef SkBenchmark_DEFINED
9 #define SkBenchmark_DEFINED 9 #define SkBenchmark_DEFINED
10 10
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkPoint.h" 12 #include "SkPoint.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "SkTRegistry.h" 14 #include "SkTRegistry.h"
15 15
16 #define DEF_BENCH(code) \ 16 #define DEF_BENCH(code) \
17 namespace { \ 17 namespace { \
18 class SK_MACRO_APPEND_LINE(F_CLASS) : public SkBenchmarkFactory { \ 18 static SkBenchmark* SK_MACRO_APPEND_LINE(factory)(void*) { code; } \
19 virtual SkBenchmark* operator()() const SK_OVERRIDE { code; } \ 19 BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(SK_MACRO_APPEND_LINE(factory)); \
20 } SK_MACRO_APPEND_LINE(g_F_); \
21 BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(&SK_MACRO_APPEND_LINE(g_F_)); \
22 } 20 }
23 21
24 /* 22 /*
25 * With the above macros, you can register benches as follows (at the bottom 23 * With the above macros, you can register benches as follows (at the bottom
26 * of your .cpp) 24 * of your .cpp)
27 * 25 *
28 * DEF_BENCH(return new MyBenchmark(...)) 26 * DEF_BENCH(return new MyBenchmark(...))
29 * DEF_BENCH(return new MyBenchmark(...)) 27 * DEF_BENCH(return new MyBenchmark(...))
30 * DEF_BENCH(return new MyBenchmark(...)) 28 * DEF_BENCH(return new MyBenchmark(...))
31 */ 29 */
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int fForceAlpha; 127 int fForceAlpha;
130 bool fForceAA; 128 bool fForceAA;
131 bool fForceFilter; 129 bool fForceFilter;
132 SkTriState::State fDither; 130 SkTriState::State fDither;
133 uint32_t fOrMask, fClearMask; 131 uint32_t fOrMask, fClearMask;
134 static SkString gResourcePath; 132 static SkString gResourcePath;
135 133
136 typedef SkRefCnt INHERITED; 134 typedef SkRefCnt INHERITED;
137 }; 135 };
138 136
139 class SkBenchmarkFactory : public SkRefCnt { 137 typedef SkTRegistry<SkBenchmark*(*)(void*)> BenchRegistry;
140 public:
141 // Creates a new SkBenchmark that is owned by the caller on each call.
142 virtual SkBenchmark* operator()() const = 0;
143 virtual ~SkBenchmarkFactory() {}
144 };
145
146 typedef SkTRegistry<SkBenchmarkFactory*> BenchRegistry;
147 138
148 #endif 139 #endif
OLDNEW
« no previous file with comments | « bench/GrMemoryPoolBench.cpp ('k') | bench/SkGMBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698