From c911edde4fe084c0b04d8a349654e186db3d5fc0 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Wed, 7 Jan 2026 17:03:41 +0100 Subject: [PATCH] IsolatedRegex bench --- benchmarks/src/LinkParser.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/benchmarks/src/LinkParser.cpp b/benchmarks/src/LinkParser.cpp index eebd3af1c..3991146c8 100644 --- a/benchmarks/src/LinkParser.cpp +++ b/benchmarks/src/LinkParser.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -41,3 +42,20 @@ static void BM_LinkParsing(benchmark::State &state) } BENCHMARK(BM_LinkParsing); + +const QRegularExpression LINK_HEURISTIC(R"(^(https?://)?[^\.]+.[^\.]{2,})"); + +static void BM_IsolatedRegex(benchmark::State &state) +{ + QStringList words = INPUT.split(' '); + + for (auto _ : state) + { + for (const auto &word : words) + { + auto ismatch = LINK_HEURISTIC.matchView(word); + benchmark::DoNotOptimize(ismatch); + } + } +} +BENCHMARK(BM_IsolatedRegex);