2012-07-24 20:47:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
2013-11-21 06:21:58 +00:00
|
|
|
virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
2012-07-24 20:47:55 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual const char* onGetName() SK_OVERRIDE {
|
|
|
|
return "writer";
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:17:16 +00:00
|
|
|
virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
|
2012-07-24 20:47:55 +00:00
|
|
|
static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
|
|
|
|
static const size_t gLen = strlen(gStr);
|
2014-01-14 20:51:26 +00:00
|
|
|
SkWriter32 writer;
|
2013-12-03 18:17:16 +00:00
|
|
|
for (int i = 0; i < loops; i++) {
|
2012-07-24 20:47:55 +00:00
|
|
|
for (size_t j = 0; j <= gLen; j++) {
|
|
|
|
writer.writeString(gStr, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkBenchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
DEF_BENCH( return new WriterBench(); )
|