Mike Reed | 4928229 | 2016-12-14 12:34:06 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 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 "SkStream.h" |
| 10 | |
| 11 | class StreamBench : public Benchmark { |
| 12 | SkString fName; |
| 13 | public: |
| 14 | StreamBench() { |
| 15 | fName.printf("wstream"); |
| 16 | } |
| 17 | |
| 18 | bool isSuitableFor(Backend backend) override { |
| 19 | return backend == kNonRendering_Backend; |
| 20 | } |
| 21 | |
| 22 | protected: |
| 23 | const char* onGetName() override { return fName.c_str(); } |
| 24 | |
| 25 | void onDraw(int loops, SkCanvas* canvas) override { |
| 26 | for (int i = 0; i < loops*100; ++i) { |
| 27 | SkDynamicMemoryWStream stream; |
| 28 | for (int j = 0; j < 100000; ++j) { |
| 29 | stream.write32(j); |
| 30 | stream.write32(j+j); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | private: |
| 36 | typedef Benchmark INHERITED; |
| 37 | }; |
| 38 | |
| 39 | /////////////////////////////////////////////////////////////////////////////// |
| 40 | |
| 41 | DEF_BENCH(return new StreamBench;) |