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

Side by Side Diff: bench/PMFloatBench.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/MutexBench.cpp ('k') | bench/PatchBench.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 2015 Google Inc. 2 * Copyright 2015 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 "SkPMFloat.h" 9 #include "SkPMFloat.h"
10 10
11 // Used to prevent the compiler from optimizing away the whole loop. 11 // Used to prevent the compiler from optimizing away the whole loop.
12 volatile uint32_t blackhole = 0; 12 volatile uint32_t blackhole = 0;
13 13
14 // Not a great random number generator, but it's very fast. 14 // Not a great random number generator, but it's very fast.
15 // The code we're measuring is quite fast, so low overhead is essential. 15 // The code we're measuring is quite fast, so low overhead is essential.
16 static uint32_t lcg_rand(uint32_t* seed) { 16 static uint32_t lcg_rand(uint32_t* seed) {
17 *seed *= 1664525; 17 *seed *= 1664525;
18 *seed += 1013904223; 18 *seed += 1013904223;
19 return *seed; 19 return *seed;
20 } 20 }
21 21
22 // I'm having better luck getting these to constant-propagate away as template p arameters. 22 // I'm having better luck getting these to constant-propagate away as template p arameters.
23 template <bool kClamp, bool kWide> 23 template <bool kClamp, bool kWide>
24 struct PMFloatBench : public Benchmark { 24 struct PMFloatBench : public Benchmark {
25 PMFloatBench() {} 25 PMFloatBench() {}
26 26
27 const char* onGetName() SK_OVERRIDE { 27 const char* onGetName() override {
28 switch (kClamp << 1 | kWide) { 28 switch (kClamp << 1 | kWide) {
29 case 0: return "SkPMFloat_get_1x"; 29 case 0: return "SkPMFloat_get_1x";
30 case 1: return "SkPMFloat_get_4x"; 30 case 1: return "SkPMFloat_get_4x";
31 case 2: return "SkPMFloat_clamp_1x"; 31 case 2: return "SkPMFloat_clamp_1x";
32 case 3: return "SkPMFloat_clamp_4x"; 32 case 3: return "SkPMFloat_clamp_4x";
33 } 33 }
34 SkFAIL("unreachable"); 34 SkFAIL("unreachable");
35 return "oh bother"; 35 return "oh bother";
36 } 36 }
37 bool isSuitableFor(Backend backend) SK_OVERRIDE { return backend == kNonRend ering_Backend; } 37 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
38 38
39 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 39 void onDraw(const int loops, SkCanvas* canvas) override {
40 // Unlike blackhole, junk can and probably will be a register. 40 // Unlike blackhole, junk can and probably will be a register.
41 uint32_t junk = 0; 41 uint32_t junk = 0;
42 uint32_t seed = 0; 42 uint32_t seed = 0;
43 for (int i = 0; i < loops; i++) { 43 for (int i = 0; i < loops; i++) {
44 SkPMColor colors[4]; 44 SkPMColor colors[4];
45 #ifdef SK_DEBUG 45 #ifdef SK_DEBUG
46 for (int i = 0; i < 4; i++) { 46 for (int i = 0; i < 4; i++) {
47 // Our SkASSERTs will remind us that it's technically required t hat we premultiply. 47 // Our SkASSERTs will remind us that it's technically required t hat we premultiply.
48 colors[i] = SkPreMultiplyColor(lcg_rand(&seed)); 48 colors[i] = SkPreMultiplyColor(lcg_rand(&seed));
49 } 49 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 blackhole ^= junk; 90 blackhole ^= junk;
91 } 91 }
92 }; 92 };
93 93
94 // Extra () help DEF_BENCH not get confused by the comma inside the <>. 94 // Extra () help DEF_BENCH not get confused by the comma inside the <>.
95 DEF_BENCH(return (new PMFloatBench< true, true>);) 95 DEF_BENCH(return (new PMFloatBench< true, true>);)
96 DEF_BENCH(return (new PMFloatBench<false, true>);) 96 DEF_BENCH(return (new PMFloatBench<false, true>);)
97 DEF_BENCH(return (new PMFloatBench< true, false>);) 97 DEF_BENCH(return (new PMFloatBench< true, false>);)
98 DEF_BENCH(return (new PMFloatBench<false, false>);) 98 DEF_BENCH(return (new PMFloatBench<false, false>);)
OLDNEW
« no previous file with comments | « bench/MutexBench.cpp ('k') | bench/PatchBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698