mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
chore: add benchmarking of ScanOpts::Matches (#4511)
Also, improve robustness of StickyEviction that was failing for me. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
fbd785cbc7
commit
2d85f59a74
1 changed files with 27 additions and 1 deletions
|
@ -498,9 +498,11 @@ TEST_F(DflyEngineTest, StickyEviction) {
|
|||
string tmp_val(100, '.');
|
||||
|
||||
ssize_t failed = -1;
|
||||
for (ssize_t i = 0; i < 5000; ++i) {
|
||||
|
||||
for (ssize_t i = 0; i < 4500; ++i) {
|
||||
string key = StrCat("volatile", i);
|
||||
ASSERT_EQ("OK", Run({"set", key, tmp_val}));
|
||||
usleep(1);
|
||||
}
|
||||
|
||||
bool done = false;
|
||||
|
@ -829,6 +831,8 @@ TEST_F(DflyEngineTest, ReplicaofRejectOnLoad) {
|
|||
ASSERT_THAT(res, ErrArg("LOADING Dragonfly is loading the dataset in memory"));
|
||||
}
|
||||
|
||||
using benchmark::DoNotOptimize;
|
||||
|
||||
// TODO: to test transactions with a single shard since then all transactions become local.
|
||||
// To consider having a parameter in dragonfly engine controlling number of shards
|
||||
// unconditionally from number of cpus. TO TEST BLPOP under multi for single/multi argument case.
|
||||
|
@ -866,4 +870,26 @@ static void BM_ParseDoubleAbsl(benchmark::State& state) {
|
|||
}
|
||||
BENCHMARK(BM_ParseDoubleAbsl);
|
||||
|
||||
static void BM_MatchPattern(benchmark::State& state) {
|
||||
absl::InsecureBitGen eng;
|
||||
string random_val = GetRandomHex(eng, state.range(0));
|
||||
ScanOpts scan_opts;
|
||||
scan_opts.pattern = "*foobar*";
|
||||
while (state.KeepRunning()) {
|
||||
DoNotOptimize(scan_opts.Matches(random_val));
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_MatchPattern)->Arg(1000)->Arg(10000);
|
||||
|
||||
static void BM_MatchFindSubstr(benchmark::State& state) {
|
||||
absl::InsecureBitGen eng;
|
||||
string random_val = GetRandomHex(eng, state.range(0));
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
DoNotOptimize(random_val.find("foobar"));
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_MatchFindSubstr)->Arg(1000)->Arg(10000);
|
||||
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue