1 2/* 3 * Copyright 2012 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include "Benchmark.h" 10#include "SkCanvas.h" 11#include "SkWriter32.h" 12 13class WriterBench : public Benchmark { 14public: 15 bool isSuitableFor(Backend backend) override { 16 return backend == kNonRendering_Backend; 17 } 18 19protected: 20 const char* onGetName() override { 21 return "writer"; 22 } 23 24 void onDraw(int loops, SkCanvas*) override { 25 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; 26 static const size_t gLen = strlen(gStr); 27 SkWriter32 writer; 28 for (int i = 0; i < loops; i++) { 29 for (size_t j = 0; j <= gLen; j++) { 30 writer.writeString(gStr, j); 31 } 32 } 33 } 34 35private: 36 typedef Benchmark INHERITED; 37}; 38 39//////////////////////////////////////////////////////////////////////////////// 40 41DEF_BENCH( return new WriterBench(); ) 42