From 46e72cbc64aaddff560f6ce36d37882ea299e642 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 29 Apr 2015 15:24:31 +0200 Subject: [PATCH] tests: Introduce perf_hash.cc, hashing benchmark Output on my laptop: $ build/release/tests/perf/perf_hash Timing fixed hash... 28671657.15 tps 28720930.45 tps 28622017.20 tps 28677088.01 tps 29223543.70 tps Timing iterator hash... 22023042.57 tps 21953352.04 tps 21393787.05 tps 21613837.10 tps 21563284.57 tps --- configure.py | 1 + tests/perf/perf_hash.cc | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/perf/perf_hash.cc diff --git a/configure.py b/configure.py index 36f05efb2c..36d9a2ebdb 100755 --- a/configure.py +++ b/configure.py @@ -158,6 +158,7 @@ urchin_tests = [ 'tests/urchin/types_test', 'tests/urchin/keys_test', 'tests/perf/perf_mutation', + 'tests/perf/perf_hash', 'tests/perf/perf_cql_parser', 'tests/perf/perf_simple_query', 'tests/urchin/cql_query_test', diff --git a/tests/perf/perf_hash.cc b/tests/perf/perf_hash.cc new file mode 100644 index 0000000000..44faeed440 --- /dev/null +++ b/tests/perf/perf_hash.cc @@ -0,0 +1,35 @@ +/* + * Copyright 2015 Cloudius Systems + */ + +#include "utils/murmur_hash.hh" +#include "tests/perf/perf.hh" + +volatile uint64_t black_hole; + +int main(int argc, char* argv[]) { + const uint64_t seed = 0; + auto src = bytes("0123412308129301923019283056789012345"); + + uint64_t sink = 0; + + std::cout << "Timing fixed hash...\n"; + + time_it([&] { + std::array dst; + utils::murmur_hash::hash3_x64_128(src, seed, dst); + sink += dst[0]; + sink += dst[1]; + }); + + std::cout << "Timing iterator hash...\n"; + + time_it([&] { + std::array dst; + utils::murmur_hash::hash3_x64_128(src.begin(), src.size(), seed, dst); + sink += dst[0]; + sink += dst[1]; + }); + + black_hole = sink; +}