OLD | NEW |
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 "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool isSuitableFor(Backend backend) override { | 112 bool isSuitableFor(Backend backend) override { |
113 return backend == kNonRendering_Backend; | 113 return backend == kNonRendering_Backend; |
114 } | 114 } |
115 | 115 |
116 protected: | 116 protected: |
117 const char* onGetName() override { | 117 const char* onGetName() override { |
118 return fName.c_str(); | 118 return fName.c_str(); |
119 } | 119 } |
120 | 120 |
121 // Delayed initialization only done if onDraw will be called. | 121 // Delayed initialization only done if onDraw will be called. |
122 void onPreDraw() override { | 122 void onDelayedSetup() override { |
123 fUnsorted.reset(N); | 123 fUnsorted.reset(N); |
124 gRec[fType].fProc(fUnsorted.get()); | 124 gRec[fType].fProc(fUnsorted.get()); |
125 } | 125 } |
126 | 126 |
127 void onDraw(const int loops, SkCanvas*) override { | 127 void onDraw(const int loops, SkCanvas*) override { |
128 SkAutoTMalloc<int> sorted(N); | 128 SkAutoTMalloc<int> sorted(N); |
129 for (int i = 0; i < loops; i++) { | 129 for (int i = 0; i < loops; i++) { |
130 memcpy(sorted.get(), fUnsorted.get(), N*sizeof(int)); | 130 memcpy(sorted.get(), fUnsorted.get(), N*sizeof(int)); |
131 fSortProc(sorted.get()); | 131 fSortProc(sorted.get()); |
132 #ifdef SK_DEBUG | 132 #ifdef SK_DEBUG |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 DEF_BENCH( return NewSkHeap(kFore); ) | 165 DEF_BENCH( return NewSkHeap(kFore); ) |
166 DEF_BENCH( return NewQSort(kFore); ) | 166 DEF_BENCH( return NewQSort(kFore); ) |
167 | 167 |
168 DEF_BENCH( return NewSkQSort(kBack); ) | 168 DEF_BENCH( return NewSkQSort(kBack); ) |
169 DEF_BENCH( return NewSkHeap(kBack); ) | 169 DEF_BENCH( return NewSkHeap(kBack); ) |
170 DEF_BENCH( return NewQSort(kBack); ) | 170 DEF_BENCH( return NewQSort(kBack); ) |
171 | 171 |
172 DEF_BENCH( return NewSkQSort(kSame); ) | 172 DEF_BENCH( return NewSkQSort(kSame); ) |
173 DEF_BENCH( return NewSkHeap(kSame); ) | 173 DEF_BENCH( return NewSkHeap(kSame); ) |
174 DEF_BENCH( return NewQSort(kSame); ) | 174 DEF_BENCH( return NewQSort(kSame); ) |
OLD | NEW |