main.cpp 681 B

123456789101112131415161718192021222324252627
  1. #include <library/cpp/testing/gbenchmark/benchmark.h>
  2. #include <util/digest/murmur.h>
  3. #include <util/system/types.h>
  4. #include <array>
  5. constexpr auto MakeTestData() {
  6. std::array<ui64, 4096> result{};
  7. for (ui64 i = 0; i < result.size(); ++i) {
  8. result[i] = i;
  9. }
  10. return result;
  11. }
  12. constexpr auto TEST_DATA = MakeTestData();
  13. template <typename Result>
  14. static void BenchmarkMurmurHash(benchmark::State& state) {
  15. for (auto _ : state) {
  16. Result hash = MurmurHash<Result>(TEST_DATA.data(), sizeof(TEST_DATA));
  17. Y_DO_NOT_OPTIMIZE_AWAY(hash);
  18. }
  19. }
  20. BENCHMARK_TEMPLATE(BenchmarkMurmurHash, ui32);
  21. BENCHMARK_TEMPLATE(BenchmarkMurmurHash, ui64);