skia2/bench/WriterBench.cpp
mtklein@google.com 410e6e80f0 Refactoring: get rid of the SkBenchmark void* parameter.
While I was doing massive sed-ing, I also converted every bench to use DEF_BENCH instead of registering the ugly manual way.

BUG=
R=scroggo@google.com

Review URL: https://codereview.chromium.org/23876006

git-svn-id: http://skia.googlecode.com/svn/trunk@11263 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-09-13 19:52:27 +00:00

40 lines
972 B
C++

/*
* Copyright 2012 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkCanvas.h"
#include "SkWriter32.h"
class WriterBench : public SkBenchmark {
public:
WriterBench() { fIsRendering = false; }
protected:
virtual const char* onGetName() SK_OVERRIDE {
return "writer";
}
virtual void onDraw(SkCanvas*) SK_OVERRIDE {
static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
static const size_t gLen = strlen(gStr);
SkWriter32 writer(256 * 4);
for (int i = 0; i < this->getLoops(); i++) {
for (size_t j = 0; j <= gLen; j++) {
writer.writeString(gStr, j);
}
}
}
private:
typedef SkBenchmark INHERITED;
};
////////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new WriterBench(); )