Skip to content

Commit e8f97dd

Browse files
committed
bench: Add seperate benchmarks for precompute and add
1 parent 02c5c75 commit e8f97dd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/bench/crypto_hash.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,37 @@ static void MuHash(benchmark::State& state)
104104
}
105105
}
106106

107+
static void MuHashPrecompute(benchmark::State& state)
108+
{
109+
FastRandomContext rng(true);
110+
MuHash3072 acc;
111+
unsigned char key[32];
112+
std::vector<unsigned char> randkey = rng.randbytes(32);
113+
for (int i = 0; i < randkey.size(); i++) {
114+
key[i] = randkey[i];
115+
}
116+
117+
while (state.KeepRunning()) {
118+
MuHash3072(key);
119+
}
120+
}
121+
122+
static void MuHashAdd(benchmark::State& state)
123+
{
124+
FastRandomContext rng(true);
125+
MuHash3072 acc;
126+
unsigned char key[32];
127+
std::vector<unsigned char> randkey = rng.randbytes(32);
128+
for (int i = 0; i < randkey.size(); i++) {
129+
key[i] = randkey[i];
130+
}
131+
132+
MuHash3072 muhash = MuHash3072(key);
133+
while (state.KeepRunning()) {
134+
acc *= muhash;
135+
}
136+
}
137+
107138
BENCHMARK(RIPEMD160, 440);
108139
BENCHMARK(SHA1, 570);
109140
BENCHMARK(SHA256, 340);
@@ -116,3 +147,5 @@ BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000);
116147
BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000);
117148

118149
BENCHMARK(MuHash, 5000);
150+
BENCHMARK(MuHashPrecompute, 5000);
151+
BENCHMARK(MuHashAdd, 5000);

0 commit comments

Comments
 (0)