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
This commit is contained in:
Tomasz Grabiec
2015-04-29 15:24:31 +02:00
parent ce78aef19a
commit 46e72cbc64
2 changed files with 36 additions and 0 deletions

View File

@@ -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',

35
tests/perf/perf_hash.cc Normal file
View File

@@ -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<uint64_t,2> 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<uint64_t,2> dst;
utils::murmur_hash::hash3_x64_128(src.begin(), src.size(), seed, dst);
sink += dst[0];
sink += dst[1];
});
black_hole = sink;
}