aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/GrMemoryPoolBench.cpp
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-10 19:23:38 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-10 19:23:38 +0000
commitc289743864e2ab926a95e617a5cd1d29b26d1825 (patch)
tree2c559da19185181efd8bd92791fb758af5969800 /bench/GrMemoryPoolBench.cpp
parent55ebe8eca0063ab1f3979d629749bc41ec409ac1 (diff)
Major bench refactoring.
- Use FLAGS_. - Remove outer repeat loop. - Tune inner loop automatically. BUG=skia:1590 R=epoger@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/23478013 git-svn-id: http://skia.googlecode.com/svn/trunk@11187 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/GrMemoryPoolBench.cpp')
-rw-r--r--bench/GrMemoryPoolBench.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/bench/GrMemoryPoolBench.cpp b/bench/GrMemoryPoolBench.cpp
index dccf8278f5..5ad1afa51c 100644
--- a/bench/GrMemoryPoolBench.cpp
+++ b/bench/GrMemoryPoolBench.cpp
@@ -34,9 +34,6 @@ GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10));
* This benchmark creates and deletes objects in stack order
*/
class GrMemoryPoolBenchStack : public SkBenchmark {
- enum {
- N = SkBENCHLOOP(1 * (1 << 20)),
- };
public:
GrMemoryPoolBenchStack(void* param) : INHERITED(param) {
fIsRendering = false;
@@ -56,13 +53,11 @@ protected:
// We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise,
// we allocate. We start allocate-biased and ping-pong to delete-biased
SkFixed delThresh = -SK_FixedHalf;
- enum {
- kSwitchThreshPeriod = N / (2 * kMaxObjects),
- };
+ const int kSwitchThreshPeriod = this->getLoops() / (2 * kMaxObjects);
int s = 0;
int count = 0;
- for (int i = 0; i < N; i++, ++s) {
+ for (int i = 0; i < this->getLoops(); i++, ++s) {
if (kSwitchThreshPeriod == s) {
delThresh = -delThresh;
s = 0;
@@ -90,9 +85,6 @@ private:
* This benchmark creates objects and deletes them in random order
*/
class GrMemoryPoolBenchRandom : public SkBenchmark {
- enum {
- N = SkBENCHLOOP(1 * (1 << 20)),
- };
public:
GrMemoryPoolBenchRandom(void* param) : INHERITED(param) {
fIsRendering = false;
@@ -109,7 +101,7 @@ protected:
};
SkAutoTDelete<A> objects[kMaxObjects];
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < this->getLoops(); i++) {
uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
if (NULL == objects[idx].get()) {
objects[idx].reset(new A);
@@ -128,8 +120,7 @@ private:
*/
class GrMemoryPoolBenchQueue : public SkBenchmark {
enum {
- N = SkBENCHLOOP((1 << 8)),
- M = SkBENCHLOOP(4 * (1 << 10)),
+ M = 4 * (1 << 10),
};
public:
GrMemoryPoolBenchQueue(void* param) : INHERITED(param) {
@@ -143,7 +134,7 @@ protected:
virtual void onDraw(SkCanvas*) {
SkRandom r;
A* objects[M];
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < this->getLoops(); i++) {
uint32_t count = r.nextRangeU(0, M-1);
for (uint32_t i = 0; i < count; i++) {
objects[i] = new A;