From 2cb545932773f5b3b8dba0e0ba2fe84dfa0a9d1b Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 28 Apr 2022 13:08:11 -0700 Subject: [PATCH] Add a benchmark that measures SkParagraph ParagraphBuilder for a simple use case (flutter/engine#32985) --- .../txt/benchmarks/skparagraph_benchmarks.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/engine/src/flutter/third_party/txt/benchmarks/skparagraph_benchmarks.cc b/engine/src/flutter/third_party/txt/benchmarks/skparagraph_benchmarks.cc index cb4775441cf..7dd27bdb6ad 100644 --- a/engine/src/flutter/third_party/txt/benchmarks/skparagraph_benchmarks.cc +++ b/engine/src/flutter/third_party/txt/benchmarks/skparagraph_benchmarks.cc @@ -299,3 +299,19 @@ BENCHMARK_F(SkParagraphFixture, PaintDecoration)(benchmark::State& state) { offset++; } } + +BENCHMARK_F(SkParagraphFixture, SimpleBuilder)(benchmark::State& state) { + const char* text = "Hello World"; + sktxt::ParagraphStyle paragraph_style; + sktxt::TextStyle text_style; + text_style.setFontFamilies({SkString("Roboto")}); + text_style.setColor(SK_ColorBLACK); + while (state.KeepRunning()) { + auto builder = + sktxt::ParagraphBuilder::make(paragraph_style, font_collection_); + builder->pushStyle(text_style); + builder->addText(text); + builder->pop(); + auto paragraph = builder->Build(); + } +}