From affcbce5caec410f987be89bad6dfee4d0c747d5 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 3 Feb 2026 13:19:42 +0100 Subject: [PATCH] [libc++][NFC] Disable std_format_spec benchmarks through lit instead of the preprocessor (#179228) This is probably a relic from when we didn't use lit to run benchmarks. Nowadays we should just use the lit features to disable benchmarks like we do in any other test instead of using the preprocessor. --- .../std_format_spec_string_unicode.bench.cpp | 24 ++++++++---------- ...ormat_spec_string_unicode_escape.bench.cpp | 25 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp b/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp index 1c859e1b2b83..eb3ffc37c882 100644 --- a/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp +++ b/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp @@ -6,17 +6,17 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 -# include -# include -# include +// UNSUPPORTED: libcpp-has-no-unicode -# include "benchmark/benchmark.h" -# include "make_string.h" -# include "test_macros.h" +#include +#include +#include -# define SV(S) MAKE_STRING_VIEW(CharT, S) +#include "benchmark/benchmark.h" +#include "make_string.h" +#include "test_macros.h" -#if _LIBCPP_HAS_UNICODE +#define SV(S) MAKE_STRING_VIEW(CharT, S) // generated with https://generator.lorem-ipsum.info/_latin @@ -285,16 +285,12 @@ BENCHMARK(BM_cyrillic_text); BENCHMARK(BM_japanese_text); BENCHMARK(BM_emoji_text); -# ifndef TEST_HAS_NO_WIDE_CHARACTERS +#ifndef TEST_HAS_NO_WIDE_CHARACTERS BENCHMARK(BM_ascii_text); BENCHMARK(BM_unicode_text); BENCHMARK(BM_cyrillic_text); BENCHMARK(BM_japanese_text); BENCHMARK(BM_emoji_text); -# endif +#endif BENCHMARK_MAIN(); - -#else -int main(int, char**) { return 0; } -#endif diff --git a/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp b/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp index 4a1eb47a71ff..aa9122979890 100644 --- a/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp +++ b/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp @@ -8,21 +8,20 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// UNSUPPORTED: libcpp-has-no-unicode + // This test formats a larger piece of text in "escaped" mode. It uses several // datasets to give an impression how the amount of multibyte UTF-8 sequences // and larger grapheme clusters affect the performance. -# include -# include -# include +#include +#include +#include -# include "benchmark/benchmark.h" -# include "make_string.h" -# include "test_macros.h" +#include "benchmark/benchmark.h" +#include "make_string.h" -#if _LIBCPP_HAS_UNICODE - -# define SV(S) MAKE_STRING_VIEW(CharT, S) +#define SV(S) MAKE_STRING_VIEW(CharT, S) // generated with https://generator.lorem-ipsum.info/_latin @@ -288,16 +287,12 @@ BENCHMARK(BM_cyrillic_escaped); BENCHMARK(BM_japanese_escaped); BENCHMARK(BM_emoji_escaped); -# ifndef TEST_HAS_NO_WIDE_CHARACTERS +#ifndef TEST_HAS_NO_WIDE_CHARACTERS BENCHMARK(BM_ascii_escaped); BENCHMARK(BM_unicode_escaped); BENCHMARK(BM_cyrillic_escaped); BENCHMARK(BM_japanese_escaped); BENCHMARK(BM_emoji_escaped); -# endif +#endif BENCHMARK_MAIN(); - -#else -int main(int, char**) { return 0; } -#endif