Skip to content

Commit

Permalink
feat, test: benchmark prefix_rank
Browse files Browse the repository at this point in the history
  • Loading branch information
SGSSGene committed Jul 22, 2024
1 parent 0ec503a commit 8039adc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test_fmindex-collection/rankvector/checkRankVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ struct Bench : ankerl::nanobench::Bench {

struct Benchs {
Bench bench_rank{"rank()"};
Bench bench_prefix_rank{"prefix_rank()"};
Bench bench_symbol{"symbol()"};
Bench bench_ctor{"c'tor"};
};
Expand All @@ -383,7 +384,7 @@ TEMPLATE_TEST_CASE("benchmark vectors c'tor,symbol() and rank() operations", "[R
return;
}

auto& [bench_rank, bench_symbol, bench_ctor] = benchs_256;
auto& [bench_rank, bench_prefix_rank, bench_symbol, bench_ctor] = benchs_256;


auto vector_name = getName<Vector>();
Expand Down Expand Up @@ -415,7 +416,12 @@ TEMPLATE_TEST_CASE("benchmark vectors c'tor,symbol() and rank() operations", "[R
});

bench_rank.minEpochIterations(2'000'000).run(vector_name, [&]() {
auto v = vec.rank(rng.bounded(text.size()), rng.bounded(4)+1);
auto v = vec.rank(rng.bounded(text.size()), rng.bounded(256));
ankerl::nanobench::doNotOptimizeAway(v);
});

bench_prefix_rank.minEpochIterations(2'000'000).run(vector_name, [&]() {
auto v = vec.prefix_rank(rng.bounded(text.size()), rng.bounded(256));
ankerl::nanobench::doNotOptimizeAway(v);
});

Expand All @@ -436,7 +442,7 @@ TEMPLATE_TEST_CASE("benchmark vectors c'tor,symbol() and rank() operations, dna4
return;
}

auto& [bench_rank, bench_symbol, bench_ctor] = benchs_5;
auto& [bench_rank, bench_prefix_rank, bench_symbol, bench_ctor] = benchs_5;


auto vector_name = getName<Vector>();
Expand Down Expand Up @@ -472,6 +478,10 @@ TEMPLATE_TEST_CASE("benchmark vectors c'tor,symbol() and rank() operations, dna4
ankerl::nanobench::doNotOptimizeAway(v);
});

bench_prefix_rank.minEpochIterations(2'000'000).run(vector_name, [&]() {
auto v = vec.prefix_rank(rng.bounded(text.size()), rng.bounded(4)+1);
ankerl::nanobench::doNotOptimizeAway(v);
});
{
auto ofs = std::stringstream{};
auto archive = cereal::BinaryOutputArchive{ofs};
Expand Down

0 comments on commit 8039adc

Please sign in to comment.