MCPcopy Create free account
hub / github.com/Snapchat/Valdi / doBenchmark

Function doBenchmark

snap_drawing/src/benchmark/main.cpp:11–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace snap::drawing;
10
11static void doBenchmark(benchmark::State& state, Valdi::Function<void(const Ref<FontManager>&)>&& benchmarkFn) {
12 auto disableCache = state.range(0) == 0;
13 auto fontManager = Valdi::makeShared<FontManager>(Valdi::ConsoleLogger::getLogger(), !disableCache);
14 fontManager->load();
15
16 auto shouldClearCacheAfterEachIteration = state.range(0) == 1;
17 for (auto _ : state) {
18 benchmarkFn(fontManager);
19
20 if (shouldClearCacheAfterEachIteration) {
21 fontManager->getTextShaper()->clearCache();
22 }
23 }
24}
25
26static void TextLayoutSimpleTextSingleLine(benchmark::State& state) {
27 doBenchmark(state, [&](const auto& fontManager) {

Callers 5

TextLayoutEmojiTextFunction · 0.85
TextLayoutArabicTextFunction · 0.85

Calls 2

loadMethod · 0.65
clearCacheMethod · 0.45

Tested by

no test coverage detected