19#include "flutter/fml/command_line.h"
20#include "flutter/fml/logging.h"
21#include "flutter/third_party/txt/tests/txt_test_utils.h"
22#include "third_party/benchmark/include/benchmark/benchmark.h"
23#include "third_party/icu/source/common/unicode/unistr.h"
40 bitmap_ = std::make_unique<SkBitmap>();
41 bitmap_->allocN32Pixels(1000, 1000);
53 const char*
text =
"Hello World";
63 auto paragraph =
builder->Build();
64 while (
state.KeepRunning()) {
65 paragraph->markDirty();
66 paragraph->layout(300);
72 "This is a very long sentence to test if the text will properly wrap "
73 "around and go to the next line. Sometimes, short sentence. Longer "
74 "sentences are okay too because they are necessary. Very short. "
75 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
76 "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
77 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
78 "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
79 "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
80 "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
81 "mollit anim id est laborum. "
82 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
83 "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
84 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
85 "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
86 "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
87 "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
88 "mollit anim id est laborum.";
98 auto paragraph =
builder->Build();
99 while (
state.KeepRunning()) {
100 paragraph->markDirty();
101 paragraph->layout(300);
107 "This is a very long sentence to test if the text will properly wrap "
108 "around and go to the next line. Sometimes, short sentence. Longer "
109 "sentences are okay too because they are necessary. Very short. "
110 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
111 "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
112 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
113 "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
114 "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
115 "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
116 "mollit anim id est laborum. "
117 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
118 "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
119 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
120 "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
121 "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
122 "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
123 "mollit anim id est laborum.";
125 paragraph_style.
setTextAlign(sktxt::TextAlign::kJustify);
131 builder->pushStyle(text_style);
134 auto paragraph =
builder->Build();
135 while (
state.KeepRunning()) {
136 paragraph->markDirty();
137 paragraph->layout(300);
142 const char*
text =
"-";
149 for (
int i = 0;
i < 1000; ++
i) {
150 builder->pushStyle(text_style);
153 auto paragraph =
builder->Build();
154 while (
state.KeepRunning()) {
155 paragraph->markDirty();
156 paragraph->layout(300);
161 std::vector<uint16_t>
text;
162 for (uint16_t
i = 0;
i <
state.range(0); ++
i) {
163 text.push_back(
i % 5 == 0 ?
' ' :
i);
165 std::u16string u16_text(
text.data(),
text.data() +
text.size());
172 builder->pushStyle(text_style);
175 auto paragraph =
builder->Build();
176 while (
state.KeepRunning()) {
177 paragraph->markDirty();
178 paragraph->layout(300);
184 ->Range(1 << 6, 1 << 14)
185 ->Complexity(benchmark::oN);
188 const char*
text =
"vry shrt ";
197 for (
int i = 0;
i < 1000; ++
i) {
198 builder->pushStyle(text_style);
201 auto paragraph =
builder->Build();
202 while (
state.KeepRunning()) {
203 paragraph->markDirty();
204 paragraph->layout(300);
210 ->Range(1 << 3, 1 << 12)
211 ->Complexity(benchmark::oN);
214 const char*
text =
"This is a simple sentence to test drawing.";
221 builder->pushStyle(text_style);
224 auto paragraph =
builder->Build();
225 paragraph->layout(300);
227 while (
state.KeepRunning()) {
228 paragraph->paint(canvas_.get(),
offset % 700, 10);
235 "Hello world! This is a simple sentence to test drawing. Hello world! "
236 "This is a simple sentence to test drawing. Hello world! This is a "
237 "simple sentence to test drawing.Hello world! This is a simple sentence "
238 "to test drawing. Hello world! "
239 "This is a simple sentence to test drawing. Hello world! This is a "
240 "simple sentence to test drawing.Hello world! This is a simple sentence "
241 "to test drawing. Hello world! "
242 "This is a simple sentence to test drawing. Hello world! This is a "
243 "simple sentence to test drawing.Hello world! This is a simple sentence "
244 "to test drawing. Hello world! "
245 "This is a simple sentence to test drawing. Hello world! This is a "
246 "simple sentence to test drawing.Hello world! This is a simple sentence "
247 "to test drawing. Hello world! "
248 "This is a simple sentence to test drawing. Hello world! This is a "
249 "simple sentence to test drawing.Hello world! This is a simple sentence "
250 "to test drawing. Hello world! "
251 "This is a simple sentence to test drawing. Hello world! This is a "
252 "simple sentence to test drawing.";
259 builder->pushStyle(text_style);
262 auto paragraph =
builder->Build();
263 paragraph->layout(300);
265 while (
state.KeepRunning()) {
266 paragraph->paint(canvas_.get(),
offset % 700, 10);
273 "Hello world! This is a simple sentence to test drawing. Hello world! "
274 "This is a simple sentence to test drawing.";
285 builder->pushStyle(text_style);
289 builder->pushStyle(text_style);
293 builder->pushStyle(text_style);
296 auto paragraph =
builder->Build();
297 paragraph->layout(300);
299 while (
state.KeepRunning()) {
300 paragraph->paint(canvas_.get(),
offset % 700, 10);
306 const char*
text =
"Hello World";
311 while (
state.KeepRunning()) {
314 builder->pushStyle(text_style);
317 auto paragraph =
builder->Build();
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
std::unique_ptr< SkCanvas > canvas_
void SetUp(const ::benchmark::State &state)
sk_sp< sktxt::TestFontCollection > font_collection_
std::unique_ptr< SkBitmap > bitmap_
static std::unique_ptr< ParagraphBuilder > make(const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
void setDecorationStyle(TextDecorationStyle style)
void setFontFamilies(std::vector< SkString > families)
void setColor(SkColor color)
void setDecoration(TextDecoration decoration)
SKUNICODE_API sk_sp< SkUnicode > Make()
const std::string & GetFontDir()
BENCHMARK_DEFINE_F(SkParagraphFixture, TextBigO)(benchmark
BENCHMARK_F(SkParagraphFixture, ShortLayout)(benchmark
void setTextAlign(TextAlign align)