72c9faab45
This fixes every case where virtual and SK_OVERRIDE were on the same line, which should be the bulk of cases. We'll have to manually clean up the rest over time unless I level up in regexes. for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end BUG=skia: Review URL: https://codereview.chromium.org/806653007
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "Benchmark.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkChunkAlloc.h"
|
|
#include "SkPaint.h"
|
|
#include "SkRandom.h"
|
|
#include "SkString.h"
|
|
|
|
class ChunkAllocBench : public Benchmark {
|
|
SkString fName;
|
|
size_t fMinSize;
|
|
public:
|
|
ChunkAllocBench(size_t minSize) {
|
|
fMinSize = minSize;
|
|
fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize);
|
|
}
|
|
|
|
bool isSuitableFor(Backend backend) SK_OVERRIDE {
|
|
return backend == kNonRendering_Backend;
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() SK_OVERRIDE {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
|
|
size_t inc = fMinSize >> 4;
|
|
SkASSERT(inc > 0);
|
|
size_t total = fMinSize * 64;
|
|
|
|
SkChunkAlloc alloc(fMinSize);
|
|
|
|
for (int i = 0; i < loops; ++i) {
|
|
size_t size = 0;
|
|
int calls = 0;
|
|
while (size < total) {
|
|
alloc.allocThrow(inc);
|
|
size += inc;
|
|
calls += 1;
|
|
}
|
|
alloc.reset();
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef Benchmark INHERITED;
|
|
};
|
|
|
|
DEF_BENCH( return new ChunkAllocBench(64); )
|
|
DEF_BENCH( return new ChunkAllocBench(8*1024); )
|
|
|