Flutter Engine
The Flutter Engine
third_party
skia
bench
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
"
9
#include "
include/core/SkStream.h
"
10
11
class
StreamBench
:
public
Benchmark
{
12
SkString
fName;
13
const
bool
fTestWrite4;
14
public
:
15
StreamBench
(
bool
testWrite4) : fTestWrite4(testWrite4) {
16
fName
.printf(
"wstream_%d"
, testWrite4);
17
}
18
19
bool
isSuitableFor
(
Backend
backend
)
override
{
20
return
backend
==
Backend::kNonRendering
;
21
}
22
23
protected
:
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
) {
30
SkDynamicMemoryWStream
stream
;
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
43
private
:
44
using
INHERITED =
Benchmark
;
45
};
46
47
///////////////////////////////////////////////////////////////////////////////
48
49
DEF_BENCH
(
return
new
StreamBench
(
false
);)
50
DEF_BENCH
(
return
new
StreamBench
(
true
);)
Benchmark.h
DEF_BENCH
#define DEF_BENCH(code)
Definition:
Benchmark.h:20
backend
const char * backend
Definition:
CommonFlagsConfig.cpp:42
fName
const char * fName
Definition:
FontCacheBench.cpp:71
SkStream.h
Benchmark
Definition:
Benchmark.h:36
Benchmark::Backend
Backend
Definition:
Benchmark.h:44
Benchmark::Backend::kNonRendering
@ kNonRendering
Benchmark::Benchmark
Benchmark()
Definition:
Benchmark.cpp:16
SkCanvas
Definition:
SkCanvas.h:106
SkDynamicMemoryWStream
Definition:
SkStream.h:455
SkString
Definition:
SkString.h:118
StreamBench
Definition:
StreamBench.cpp:11
StreamBench::StreamBench
StreamBench(bool testWrite4)
Definition:
StreamBench.cpp:15
StreamBench::isSuitableFor
bool isSuitableFor(Backend backend) override
Definition:
StreamBench.cpp:19
StreamBench::onDraw
void onDraw(int loops, SkCanvas *canvas) override
Definition:
StreamBench.cpp:26
StreamBench::onGetName
const char * onGetName() override
Definition:
StreamBench.cpp:24
i
int i
Definition:
fl_socket_accessible.cc:18
dart_profiler_symbols.stream
stream
Definition:
dart_profiler_symbols.py:81
Generated on Sun Jun 23 2024 21:55:54 for Flutter Engine by
1.9.4