1 // Copyright (c) 2016-2018 The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 5 #include <iostream> 6 7 #include <bench/bench.h> 8 #include <bloom.h> 9 RollingBloom(benchmark::State & state)10static void RollingBloom(benchmark::State& state) 11 { 12 CRollingBloomFilter filter(120000, 0.000001); 13 std::vector<unsigned char> data(32); 14 uint32_t count = 0; 15 while (state.KeepRunning()) { 16 count++; 17 data[0] = count; 18 data[1] = count >> 8; 19 data[2] = count >> 16; 20 data[3] = count >> 24; 21 filter.insert(data); 22 23 data[0] = count >> 24; 24 data[1] = count >> 16; 25 data[2] = count >> 8; 26 data[3] = count; 27 filter.contains(data); 28 } 29 } 30 31 BENCHMARK(RollingBloom, 1500 * 1000); 32