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

Side by Side Diff: bench/MemcpyBench.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/MatrixBench.cpp ('k') | bench/MemoryBench.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 2014 Google Inc. 2 * Copyright 2014 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 "SkRandom.h" 9 #include "SkRandom.h"
10 #include "SkTemplates.h" 10 #include "SkTemplates.h"
11 #include "SkUtils.h" 11 #include "SkUtils.h"
12 12
13 template <typename Memcpy32> 13 template <typename Memcpy32>
14 class Memcpy32Bench : public Benchmark { 14 class Memcpy32Bench : public Benchmark {
15 public: 15 public:
16 explicit Memcpy32Bench(int count, Memcpy32 memcpy32, const char* name) 16 explicit Memcpy32Bench(int count, Memcpy32 memcpy32, const char* name)
17 : fCount(count) 17 : fCount(count)
18 , fMemcpy32(memcpy32) 18 , fMemcpy32(memcpy32)
19 , fName(SkStringPrintf("%s_%d", name, count)) {} 19 , fName(SkStringPrintf("%s_%d", name, count)) {}
20 20
21 virtual const char* onGetName() SK_OVERRIDE { 21 const char* onGetName() SK_OVERRIDE {
22 return fName.c_str(); 22 return fName.c_str();
23 } 23 }
24 24
25 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 25 bool isSuitableFor(Backend backend) SK_OVERRIDE {
26 return backend == kNonRendering_Backend; 26 return backend == kNonRendering_Backend;
27 } 27 }
28 28
29 virtual void onPreDraw() SK_OVERRIDE { 29 void onPreDraw() SK_OVERRIDE {
30 fDst.reset(fCount); 30 fDst.reset(fCount);
31 fSrc.reset(fCount); 31 fSrc.reset(fCount);
32 32
33 SkRandom rand; 33 SkRandom rand;
34 for (int i = 0; i < fCount; i++) { 34 for (int i = 0; i < fCount; i++) {
35 fSrc[i] = rand.nextU(); 35 fSrc[i] = rand.nextU();
36 } 36 }
37 } 37 }
38 38
39 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 39 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
40 for (int i = 0; i < loops; i++) { 40 for (int i = 0; i < loops; i++) {
41 fMemcpy32(fDst, fSrc, fCount); 41 fMemcpy32(fDst, fSrc, fCount);
42 } 42 }
43 } 43 }
44 44
45 private: 45 private:
46 SkAutoTMalloc<uint32_t> fDst, fSrc; 46 SkAutoTMalloc<uint32_t> fDst, fSrc;
47 47
48 int fCount; 48 int fCount;
49 Memcpy32 fMemcpy32; 49 Memcpy32 fMemcpy32;
(...skipping 18 matching lines...) Expand all
68 BENCH(memcpy32_memcpy, 100000) 68 BENCH(memcpy32_memcpy, 100000)
69 69
70 // Test our chosen best, from SkUtils.h 70 // Test our chosen best, from SkUtils.h
71 BENCH(sk_memcpy32, 10) 71 BENCH(sk_memcpy32, 10)
72 BENCH(sk_memcpy32, 100) 72 BENCH(sk_memcpy32, 100)
73 BENCH(sk_memcpy32, 1000) 73 BENCH(sk_memcpy32, 1000)
74 BENCH(sk_memcpy32, 10000) 74 BENCH(sk_memcpy32, 10000)
75 BENCH(sk_memcpy32, 100000) 75 BENCH(sk_memcpy32, 100000)
76 76
77 #undef BENCH 77 #undef BENCH
OLDNEW
« no previous file with comments | « bench/MatrixBench.cpp ('k') | bench/MemoryBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698