Changeset View
Changeset View
Standalone View
Standalone View
src/bench/crypto_hash.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | static void SipHash_32b(benchmark::State &state) { | ||||
uint64_t k1 = 0; | uint64_t k1 = 0; | ||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
*((uint64_t *)x.begin()) = SipHashUint256(0, ++k1, x); | *((uint64_t *)x.begin()) = SipHashUint256(0, ++k1, x); | ||||
} | } | ||||
} | } | ||||
static void FastRandom_32bit(benchmark::State &state) { | static void FastRandom_32bit(benchmark::State &state) { | ||||
FastRandomContext rng(true); | FastRandomContext rng(true); | ||||
uint32_t x = 0; | |||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
x += rng.rand32(); | rng.rand32(); | ||||
} | } | ||||
} | } | ||||
static void FastRandom_1bit(benchmark::State &state) { | static void FastRandom_1bit(benchmark::State &state) { | ||||
FastRandomContext rng(true); | FastRandomContext rng(true); | ||||
uint32_t x = 0; | |||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
x += rng.randbool(); | rng.randbool(); | ||||
} | } | ||||
} | } | ||||
BENCHMARK(RIPEMD160, 440); | BENCHMARK(RIPEMD160, 440); | ||||
BENCHMARK(SHA1, 570); | BENCHMARK(SHA1, 570); | ||||
BENCHMARK(SHA256, 340); | BENCHMARK(SHA256, 340); | ||||
BENCHMARK(SHA512, 330); | BENCHMARK(SHA512, 330); | ||||
BENCHMARK(SHA256_32b, 4700 * 1000); | BENCHMARK(SHA256_32b, 4700 * 1000); | ||||
BENCHMARK(SipHash_32b, 40 * 1000 * 1000); | BENCHMARK(SipHash_32b, 40 * 1000 * 1000); | ||||
BENCHMARK(SHA256D64_1024, 7400); | BENCHMARK(SHA256D64_1024, 7400); | ||||
BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000); | BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000); | ||||
BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000); | BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000); |