2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "SkChunkAlloc.h"
15 class ChunkAllocBench : public Benchmark {
19 ChunkAllocBench(size_t minSize) {
21 fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize);
24 bool isSuitableFor(Backend backend) SK_OVERRIDE {
25 return backend == kNonRendering_Backend;
29 const char* onGetName() SK_OVERRIDE {
33 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
34 size_t inc = fMinSize >> 4;
36 size_t total = fMinSize * 64;
38 SkChunkAlloc alloc(fMinSize);
40 for (int i = 0; i < loops; ++i) {
43 while (size < total) {
44 alloc.allocThrow(inc);
53 typedef Benchmark INHERITED;
56 DEF_BENCH( return new ChunkAllocBench(64); )
57 DEF_BENCH( return new ChunkAllocBench(8*1024); )