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

Side by Side Diff: bench/MemsetBench.cpp

Issue 1379923005: Remove const from `const int loops`. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: n too Created 5 years, 2 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/MemoryBench.cpp ('k') | bench/MergeBench.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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkTemplates.h" 9 #include "SkTemplates.h"
10 #include "SkUtils.h" 10 #include "SkUtils.h"
11 11
12 template <typename T, bool kInline> 12 template <typename T, bool kInline>
13 class MemsetBench : public Benchmark { 13 class MemsetBench : public Benchmark {
14 public: 14 public:
15 explicit MemsetBench(int n) 15 explicit MemsetBench(int n)
16 : fN(n) 16 : fN(n)
17 , fBuffer(n) 17 , fBuffer(n)
18 , fName(SkStringPrintf("memset%d_%d%s", sizeof(T)*8, n, kInline ? "_inli ne" : "")) {} 18 , fName(SkStringPrintf("memset%d_%d%s", sizeof(T)*8, n, kInline ? "_inli ne" : "")) {}
19 19
20 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; } 20 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
21 const char* onGetName() override { return fName.c_str(); } 21 const char* onGetName() override { return fName.c_str(); }
22 22
23 void onDraw(const int loops, SkCanvas*) override; 23 void onDraw(int loops, SkCanvas*) override;
24 24
25 private: 25 private:
26 int fN; 26 int fN;
27 SkAutoTMalloc<T> fBuffer; 27 SkAutoTMalloc<T> fBuffer;
28 SkString fName; 28 SkString fName;
29 }; 29 };
30 30
31 template <> void MemsetBench<uint32_t, false>::onDraw(const int loops, SkCanvas* ) { 31 template <> void MemsetBench<uint32_t, false>::onDraw(int loops, SkCanvas*) {
32 for (int i = 0; i < 1000*loops; i++) { 32 for (int i = 0; i < 1000*loops; i++) {
33 sk_memset32(fBuffer.get(), 0xFACEB004, fN); 33 sk_memset32(fBuffer.get(), 0xFACEB004, fN);
34 } 34 }
35 } 35 }
36 36
37 template <> void MemsetBench<uint16_t, false>::onDraw(const int loops, SkCanvas* ) { 37 template <> void MemsetBench<uint16_t, false>::onDraw(int loops, SkCanvas*) {
38 for (int i = 0; i < 1000*loops; i++) { 38 for (int i = 0; i < 1000*loops; i++) {
39 sk_memset16(fBuffer.get(), 0x4973, fN); 39 sk_memset16(fBuffer.get(), 0x4973, fN);
40 } 40 }
41 } 41 }
42 42
43 template <typename T> 43 template <typename T>
44 static void memsetT(T* dst, T val, int n) { 44 static void memsetT(T* dst, T val, int n) {
45 for (int i = 0; i < n; i++) { dst[i] = val; } 45 for (int i = 0; i < n; i++) { dst[i] = val; }
46 } 46 }
47 47
48 template <> void MemsetBench<uint32_t, true>::onDraw(const int loops, SkCanvas*) { 48 template <> void MemsetBench<uint32_t, true>::onDraw(int loops, SkCanvas*) {
49 for (int i = 0; i < 1000*loops; i++) { 49 for (int i = 0; i < 1000*loops; i++) {
50 memsetT<uint32_t>(fBuffer.get(), 0xFACEB004, fN); 50 memsetT<uint32_t>(fBuffer.get(), 0xFACEB004, fN);
51 } 51 }
52 } 52 }
53 53
54 template <> void MemsetBench<uint16_t, true>::onDraw(const int loops, SkCanvas*) { 54 template <> void MemsetBench<uint16_t, true>::onDraw(int loops, SkCanvas*) {
55 for (int i = 0; i < 1000*loops; i++) { 55 for (int i = 0; i < 1000*loops; i++) {
56 memsetT<uint16_t>(fBuffer.get(), 0x4973, fN); 56 memsetT<uint16_t>(fBuffer.get(), 0x4973, fN);
57 } 57 }
58 } 58 }
59 59
60 DEF_BENCH(return (new MemsetBench<uint32_t, true>(1))); 60 DEF_BENCH(return (new MemsetBench<uint32_t, true>(1)));
61 DEF_BENCH(return (new MemsetBench<uint32_t, false>(1))); 61 DEF_BENCH(return (new MemsetBench<uint32_t, false>(1)));
62 DEF_BENCH(return (new MemsetBench<uint32_t, true>(10))); 62 DEF_BENCH(return (new MemsetBench<uint32_t, true>(10)));
63 DEF_BENCH(return (new MemsetBench<uint32_t, false>(10))); 63 DEF_BENCH(return (new MemsetBench<uint32_t, false>(10)));
64 DEF_BENCH(return (new MemsetBench<uint32_t, true>(100))); 64 DEF_BENCH(return (new MemsetBench<uint32_t, true>(100)));
(...skipping 10 matching lines...) Expand all
75 DEF_BENCH(return (new MemsetBench<uint16_t, true>(10))); 75 DEF_BENCH(return (new MemsetBench<uint16_t, true>(10)));
76 DEF_BENCH(return (new MemsetBench<uint16_t, false>(10))); 76 DEF_BENCH(return (new MemsetBench<uint16_t, false>(10)));
77 DEF_BENCH(return (new MemsetBench<uint16_t, true>(100))); 77 DEF_BENCH(return (new MemsetBench<uint16_t, true>(100)));
78 DEF_BENCH(return (new MemsetBench<uint16_t, false>(100))); 78 DEF_BENCH(return (new MemsetBench<uint16_t, false>(100)));
79 DEF_BENCH(return (new MemsetBench<uint16_t, true>(1000))); 79 DEF_BENCH(return (new MemsetBench<uint16_t, true>(1000)));
80 DEF_BENCH(return (new MemsetBench<uint16_t, false>(1000))); 80 DEF_BENCH(return (new MemsetBench<uint16_t, false>(1000)));
81 DEF_BENCH(return (new MemsetBench<uint16_t, true>(10000))); 81 DEF_BENCH(return (new MemsetBench<uint16_t, true>(10000)));
82 DEF_BENCH(return (new MemsetBench<uint16_t, false>(10000))); 82 DEF_BENCH(return (new MemsetBench<uint16_t, false>(10000)));
83 DEF_BENCH(return (new MemsetBench<uint16_t, true>(100000))); 83 DEF_BENCH(return (new MemsetBench<uint16_t, true>(100000)));
84 DEF_BENCH(return (new MemsetBench<uint16_t, false>(100000))); 84 DEF_BENCH(return (new MemsetBench<uint16_t, false>(100000)));
OLDNEW
« no previous file with comments | « bench/MemoryBench.cpp ('k') | bench/MergeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698