mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Add GCSFilterDecode and GCSBlockFilterGetHash benchmarks.
All of the benchmarks are standardized on the BASIC filter parameters so we can compare between all the benchmarks. All the GCS benchmarks are renamed to have "GCS" as the prefix.
This commit is contained in:
parent
b0a53d50d9
commit
299023c1d9
1 changed files with 42 additions and 15 deletions
|
@ -5,7 +5,7 @@
|
|||
#include <bench/bench.h>
|
||||
#include <blockfilter.h>
|
||||
|
||||
static void ConstructGCSFilter(benchmark::Bench& bench)
|
||||
static const GCSFilter::ElementSet GenerateGCSTestElements()
|
||||
{
|
||||
GCSFilter::ElementSet elements;
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
|
@ -15,29 +15,56 @@ static void ConstructGCSFilter(benchmark::Bench& bench)
|
|||
elements.insert(std::move(element));
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
static void GCSBlockFilterGetHash(benchmark::Bench& bench)
|
||||
{
|
||||
auto elements = GenerateGCSTestElements();
|
||||
|
||||
GCSFilter filter({0, 0, BASIC_FILTER_P, BASIC_FILTER_M}, elements);
|
||||
BlockFilter block_filter(BlockFilterType::BASIC, {}, filter.GetEncoded(), /*skip_decode_check=*/false);
|
||||
|
||||
bench.run([&] {
|
||||
block_filter.GetHash();
|
||||
});
|
||||
}
|
||||
|
||||
static void GCSFilterConstruct(benchmark::Bench& bench)
|
||||
{
|
||||
auto elements = GenerateGCSTestElements();
|
||||
|
||||
uint64_t siphash_k0 = 0;
|
||||
bench.batch(elements.size()).unit("elem").run([&] {
|
||||
GCSFilter filter({siphash_k0, 0, 20, 1 << 20}, elements);
|
||||
GCSFilter filter({siphash_k0, 0, BASIC_FILTER_P, BASIC_FILTER_M}, elements);
|
||||
|
||||
siphash_k0++;
|
||||
});
|
||||
}
|
||||
|
||||
static void MatchGCSFilter(benchmark::Bench& bench)
|
||||
static void GCSFilterDecode(benchmark::Bench& bench)
|
||||
{
|
||||
GCSFilter::ElementSet elements;
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
GCSFilter::Element element(32);
|
||||
element[0] = static_cast<unsigned char>(i);
|
||||
element[1] = static_cast<unsigned char>(i >> 8);
|
||||
elements.insert(std::move(element));
|
||||
}
|
||||
GCSFilter filter({0, 0, 20, 1 << 20}, elements);
|
||||
auto elements = GenerateGCSTestElements();
|
||||
|
||||
bench.unit("elem").run([&] {
|
||||
filter.Match(GCSFilter::Element());
|
||||
GCSFilter filter({0, 0, BASIC_FILTER_P, BASIC_FILTER_M}, elements);
|
||||
auto encoded = filter.GetEncoded();
|
||||
|
||||
bench.run([&] {
|
||||
GCSFilter filter({0, 0, BASIC_FILTER_P, BASIC_FILTER_M}, encoded, /*skip_decode_check=*/false);
|
||||
});
|
||||
}
|
||||
|
||||
BENCHMARK(ConstructGCSFilter);
|
||||
BENCHMARK(MatchGCSFilter);
|
||||
static void GCSFilterMatch(benchmark::Bench& bench)
|
||||
{
|
||||
auto elements = GenerateGCSTestElements();
|
||||
|
||||
GCSFilter filter({0, 0, BASIC_FILTER_P, BASIC_FILTER_M}, elements);
|
||||
|
||||
bench.run([&] {
|
||||
filter.Match(GCSFilter::Element());
|
||||
});
|
||||
}
|
||||
BENCHMARK(GCSBlockFilterGetHash);
|
||||
BENCHMARK(GCSFilterConstruct);
|
||||
BENCHMARK(GCSFilterDecode);
|
||||
BENCHMARK(GCSFilterMatch);
|
||||
|
|
Loading…
Add table
Reference in a new issue