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