From 5094b5f3fb9a59dda77090960cf868d08f915a29 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Fri, 28 Jul 2023 20:54:30 +0200 Subject: [PATCH] Add style targetted benchmark. --- src/ftxui/dom/benchmark_test.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/ftxui/dom/benchmark_test.cpp b/src/ftxui/dom/benchmark_test.cpp index a46d9f94a..535dde6ad 100644 --- a/src/ftxui/dom/benchmark_test.cpp +++ b/src/ftxui/dom/benchmark_test.cpp @@ -1,3 +1,4 @@ +#include #include #include "ftxui/dom/elements.hpp" // for gauge, separator, operator|, text, Element, hbox, vbox, blink, border, inverted @@ -43,9 +44,38 @@ static void BencharkText(benchmark::State& state) { } BENCHMARK(BencharkText)->DenseRange(0, 10, 1); +static void BenchmarkStyle(benchmark::State& state) { + while (state.KeepRunning()) { + Elements elements; + for (int i = 0; i < state.range(0); ++i) { + elements.push_back(vbox({ + text("Test") | bold, + text("Test") | dim, + text("Test") | inverted, + text("Test") | underlined, + text("Test") | underlinedDouble, + text("Test") | strikethrough, + text("Test") | color(Color::Red), + text("Test") | bgcolor(Color::Red), + text("Test") | blink, + text("Test") | automerge, + })); + elements.push_back(separator()); + } + auto document = hbox(std::move(elements)); + Screen screen(state.range(1), state.range(1)); + Render(screen, document); + } +} +BENCHMARK(BenchmarkStyle) + ->ArgsProduct({ + benchmark::CreateDenseRange(1, 10, 3), // Number of elements. + benchmark::CreateDenseRange(10, 200, 20), // Screen width. + }); + } // namespace ftxui // NOLINTEND // Copyright 2021 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in -// the LICENSE file.l +// the LICENSE file.