2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
13 class MemsetBench : public Benchmark {
31 MemsetBench(MemsetType type, int minSize, int maxSize) {
32 SkASSERT((minSize < maxSize) && (maxSize <= kBufferSize));
35 fName.printf("memset%d_%d_%d", type, minSize, maxSize);
38 bool isSuitableFor(Backend backend) override {
39 return backend == kNonRendering_Backend;
42 virtual void performTest() = 0;
45 const char* onGetName() override {
49 void onDraw(const int loops, SkCanvas* canvas) override {
50 for (int i = 0; i < loops; ++i) {
56 typedef Benchmark INHERITED;
59 class Memset32Bench : public MemsetBench {
60 uint32_t kBuffer[kBufferSize + 3];
62 Memset32Bench(int minSize, int maxSize)
63 : INHERITED(MEMSET32, minSize, maxSize) {}
66 void performTest() override {
67 for(int j = fMinSize; j < fMaxSize; ++j){
68 sk_memset32(kBuffer, VALUE32, j);
69 sk_memset32(kBuffer + 1, VALUE32, j);
70 sk_memset32(kBuffer + 2, VALUE32, j);
71 sk_memset32(kBuffer + 3, VALUE32, j);
75 typedef MemsetBench INHERITED;
78 class Memset16Bench : public MemsetBench {
79 uint16_t kBuffer[kBufferSize + 7];
81 Memset16Bench(int minSize, int maxSize)
82 : INHERITED(MEMSET16, minSize, maxSize) {}
85 void performTest() override {
86 for(int j = fMinSize; j < fMaxSize; ++j){
87 sk_memset16(kBuffer, VALUE16, j);
88 sk_memset16(kBuffer + 1, VALUE16, j);
89 sk_memset16(kBuffer + 2, VALUE16, j);
90 sk_memset16(kBuffer + 3, VALUE16, j);
91 sk_memset16(kBuffer + 4, VALUE16, j);
92 sk_memset16(kBuffer + 5, VALUE16, j);
93 sk_memset16(kBuffer + 6, VALUE16, j);
94 sk_memset16(kBuffer + 7, VALUE16, j);
98 typedef MemsetBench INHERITED;
101 DEF_BENCH(return new Memset32Bench(1, 600);)
102 DEF_BENCH(return new Memset32Bench(600, 800);)
103 DEF_BENCH(return new Memset32Bench(800, 1000);)
104 DEF_BENCH(return new Memset32Bench(1000, 2000);)
105 DEF_BENCH(return new Memset32Bench(2000, 3000);)
106 DEF_BENCH(return new Memset32Bench(3000, 4000);)
107 DEF_BENCH(return new Memset32Bench(4000, 5000);)
109 DEF_BENCH(return new Memset16Bench(1, 600);)
110 DEF_BENCH(return new Memset16Bench(600, 800);)
111 DEF_BENCH(return new Memset16Bench(800, 1000);)
112 DEF_BENCH(return new Memset16Bench(1000, 2000);)
113 DEF_BENCH(return new Memset16Bench(2000, 3000);)
114 DEF_BENCH(return new Memset16Bench(3000, 4000);)
115 DEF_BENCH(return new Memset16Bench(4000, 5000);)