Flutter Engine
paint_record_benchmarks.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "flutter/fml/command_line.h"
18 #include "flutter/fml/logging.h"
19 #include "flutter/third_party/txt/tests/txt_test_utils.h"
20 #include "third_party/benchmark/include/benchmark/benchmark_api.h"
21 #include "txt/paint_record.h"
22 #include "txt/text_style.h"
23 
24 namespace txt {
25 
26 static void BM_PaintRecordInit(benchmark::State& state) {
27  TextStyle style;
28  style.font_families = std::vector<std::string>(1, "Roboto");
29 
30  SkFont font;
31  font.setEdging(SkFont::Edging::kAntiAlias);
32  font.setSize(14);
33  font.setEmbolden(false);
34 
35  SkTextBlobBuilder builder;
36  builder.allocRunPos(font, 100);
37  auto text_blob = builder.make();
38 
39  while (state.KeepRunning()) {
40  PaintRecord PaintRecord(style, text_blob, SkFontMetrics(), 0, 0, 0, false);
41  }
42 }
44 
45 } // namespace txt
BENCHMARK(BM_PaintRecordInit)
static void BM_PaintRecordInit(benchmark::State &state)
std::vector< std::string > font_families
Definition: text_style.h:49