Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
StreamBench.cpp
Go to the documentation of this file.
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 "bench/Benchmark.h"
10
11class StreamBench : public Benchmark {
12 SkString fName;
13 const bool fTestWrite4;
14public:
15 StreamBench(bool testWrite4) : fTestWrite4(testWrite4) {
16 fName.printf("wstream_%d", testWrite4);
17 }
18
19 bool isSuitableFor(Backend backend) override {
21 }
22
23protected:
24 const char* onGetName() override { return fName.c_str(); }
25
26 void onDraw(int loops, SkCanvas* canvas) override {
27 const char t3[] = { 1, 2, 3 };
28 const char t5[] = { 1, 2, 3, 4, 5 };
29 for (int i = 0; i < loops*100; ++i) {
31 for (int j = 0; j < 10000; ++j) {
32 if (fTestWrite4) {
33 stream.write32(j);
34 stream.write32(j+j);
35 } else {
36 stream.write(t3, 3);
37 stream.write(t5, 5);
38 }
39 }
40 }
41 }
42
43private:
44 using INHERITED = Benchmark;
45};
46
47///////////////////////////////////////////////////////////////////////////////
48
49DEF_BENCH(return new StreamBench(false);)
50DEF_BENCH(return new StreamBench(true);)
#define DEF_BENCH(code)
Definition Benchmark.h:20
const char * backend
const char * fName
StreamBench(bool testWrite4)
bool isSuitableFor(Backend backend) override
void onDraw(int loops, SkCanvas *canvas) override
const char * onGetName() override