mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
chore: add reflex matcher to the benchmarks (#4520)
Add a test covering stringmatchlen. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
efb7861cee
commit
f2309f4e7b
2 changed files with 77 additions and 0 deletions
|
@ -13,6 +13,7 @@ extern "C" {
|
|||
#include <absl/strings/strip.h>
|
||||
#include <fast_float/fast_float.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <reflex/matcher.h>
|
||||
|
||||
#include "base/flags.h"
|
||||
#include "base/gtest.h"
|
||||
|
@ -891,5 +892,37 @@ static void BM_MatchFindSubstr(benchmark::State& state) {
|
|||
}
|
||||
BENCHMARK(BM_MatchFindSubstr)->Arg(1000)->Arg(10000);
|
||||
|
||||
static void BM_MatchReflexFind(benchmark::State& state) {
|
||||
absl::InsecureBitGen eng;
|
||||
string random_val = GetRandomHex(eng, state.range(0));
|
||||
reflex::Matcher matcher("foobar");
|
||||
matcher.input("xxxxxxfoobaryyyyyyyy");
|
||||
CHECK_GT(matcher.find(), 0u);
|
||||
matcher.input("xxxxxxfoobayyyyyyyy");
|
||||
CHECK_EQ(0u, matcher.find());
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
matcher.input(random_val);
|
||||
DoNotOptimize(matcher.find());
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_MatchReflexFind)->Arg(1000)->Arg(10000);
|
||||
|
||||
static void BM_MatchReflexMatch(benchmark::State& state) {
|
||||
absl::InsecureBitGen eng;
|
||||
string random_val = GetRandomHex(eng, state.range(0));
|
||||
reflex::Matcher matcher(".*foobar.*");
|
||||
matcher.input("xxxxxxfoobaryyyyyyyy");
|
||||
CHECK_GT(matcher.matches(), 0u);
|
||||
matcher.input("xxxxxxfoobayyyyyyyy");
|
||||
CHECK_EQ(0u, matcher.matches());
|
||||
|
||||
matcher.input(random_val);
|
||||
while (state.KeepRunning()) {
|
||||
matcher.input(random_val);
|
||||
DoNotOptimize(matcher.matches());
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_MatchReflexMatch)->Arg(1000)->Arg(10000);
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue