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.
|
|
|
|
*/
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
#include "Benchmark.h"
|
2012-07-24 20:47:55 +00:00
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkWriter32.h"
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
class WriterBench : public Benchmark {
|
2012-07-24 20:47:55 +00:00
|
|
|
public:
|
2015-03-26 01:17:31 +00:00
|
|
|
bool isSuitableFor(Backend backend) override {
|
2013-11-21 06:21:58 +00:00
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
2012-07-24 20:47:55 +00:00
|
|
|
|
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* onGetName() override {
|
2012-07-24 20:47:55 +00:00
|
|
|
return "writer";
|
|
|
|
}
|
|
|
|
|
2015-10-01 16:43:39 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) 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:
|
2014-06-19 19:32:29 +00:00
|
|
|
typedef Benchmark INHERITED;
|
2012-07-24 20:47:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
DEF_BENCH( return new WriterBench(); )
|