Skip to content

Commit

Permalink
Merge pull request bitcoin#1141 from sickpig/reenable-bench-code
Browse files Browse the repository at this point in the history
Reenable SipHash and FastRandomContext bench code
  • Loading branch information
gandrewstone committed Jun 21, 2018
2 parents fcdf663 + 89b2d2f commit da97a2e
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/bench/crypto_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,46 +62,50 @@ static void SHA512(benchmark::State &state)
CSHA512().Write(in.data(), in.size()).Finalize(hash);
}

#if 0
static void SipHash_32b(benchmark::State& state)
static void SipHash_32b(benchmark::State &state)
{
uint256 x;
while (state.KeepRunning()) {
for (int i = 0; i < 1000000; i++) {
*((uint64_t*)x.begin()) = SipHashUint256(0, i, x);
while (state.KeepRunning())
{
for (int i = 0; i < 1000000; i++)
{
*((uint64_t *)x.begin()) = SipHashUint256(0, i, x);
}
}
}

static void FastRandom_32bit(benchmark::State& state)
static void FastRandom_32bit(benchmark::State &state)
{
FastRandomContext rng(true);
uint32_t x = 0;
while (state.KeepRunning()) {
for (int i = 0; i < 1000000; i++) {
while (state.KeepRunning())
{
for (int i = 0; i < 1000000; i++)
{
x += rng.rand32();
}
}
}

static void FastRandom_1bit(benchmark::State& state)
static void FastRandom_1bit(benchmark::State &state)
{
FastRandomContext rng(true);
uint32_t x = 0;
while (state.KeepRunning()) {
for (int i = 0; i < 1000000; i++) {
while (state.KeepRunning())
{
for (int i = 0; i < 1000000; i++)
{
x += rng.randbool();
}
}
}
#endif

BENCHMARK(RIPEMD160);
BENCHMARK(SHA1);
BENCHMARK(SHA256);
BENCHMARK(SHA512);

BENCHMARK(SHA256_32b);
// BENCHMARK(SipHash_32b);
// BENCHMARK(FastRandom_32bit);
// BENCHMARK(FastRandom_1bit);
BENCHMARK(SipHash_32b);
BENCHMARK(FastRandom_32bit);
BENCHMARK(FastRandom_1bit);

0 comments on commit da97a2e

Please sign in to comment.