aboutsummaryrefslogtreecommitdiffstats
path: root/util/digest/benchmark/murmur/main.cpp
blob: ee916bece7694d9edd5522fd0ff2e7ea57d5cfac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <library/cpp/testing/gbenchmark/benchmark.h>

#include <util/digest/murmur.h>
#include <util/system/types.h>

#include <array>

constexpr auto MakeTestData() {
    std::array<ui64, 4096> result{};
    for (ui64 i = 0; i < result.size(); ++i) {
        result[i] = i;
    }
    return result;
}

constexpr auto TEST_DATA = MakeTestData();

template <typename Result>
static void BenchmarkMurmurHash(benchmark::State& state) {
    for (auto _ : state) {
        Result hash = MurmurHash<Result>(TEST_DATA.data(), sizeof(TEST_DATA));
        Y_DO_NOT_OPTIMIZE_AWAY(hash);
    }
}

BENCHMARK_TEMPLATE(BenchmarkMurmurHash, ui32);
BENCHMARK_TEMPLATE(BenchmarkMurmurHash, ui64);