Skip to content

Commit

Permalink
bench: Add seperate benchmarks for precompute and add
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Nov 8, 2019
1 parent 3d3da6a commit a95373a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/bench/crypto_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ static void MuHash(benchmark::State& state)
}
}

static void MuHashPrecompute(benchmark::State& state)
{
FastRandomContext rng(true);
MuHash3072 acc;
unsigned char key[32];
std::vector<unsigned char> randkey = rng.randbytes(32);
for (int i = 0; i < randkey.size(); i++) {
key[i] = randkey[i];
}

while (state.KeepRunning()) {
MuHash3072(key);
}
}

static void MuHashAdd(benchmark::State& state)
{
FastRandomContext rng(true);
MuHash3072 acc;
unsigned char key[32];
std::vector<unsigned char> randkey = rng.randbytes(32);
for (int i = 0; i < randkey.size(); i++) {
key[i] = randkey[i];
}

MuHash3072 muhash = MuHash3072(key);
while (state.KeepRunning()) {
acc *= muhash;
}
}

BENCHMARK(RIPEMD160, 440);
BENCHMARK(SHA1, 570);
BENCHMARK(SHA256, 340);
Expand All @@ -116,3 +147,5 @@ BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000);
BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000);

BENCHMARK(MuHash, 5000);
BENCHMARK(MuHashPrecompute, 5000);
BENCHMARK(MuHashAdd, 5000);

0 comments on commit a95373a

Please sign in to comment.