mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
bench: Add Muhash benchmarks
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
This commit is contained in:
parent
7b1242229d
commit
c122527385
1 changed files with 54 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
#include <crypto/muhash.h>
|
||||||
#include <crypto/ripemd160.h>
|
#include <crypto/ripemd160.h>
|
||||||
#include <crypto/sha1.h>
|
#include <crypto/sha1.h>
|
||||||
#include <crypto/sha256.h>
|
#include <crypto/sha256.h>
|
||||||
|
@ -105,6 +106,54 @@ static void FastRandom_1bit(benchmark::Bench& bench)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MuHash(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
MuHash3072 acc;
|
||||||
|
unsigned char key[32] = {0};
|
||||||
|
int i = 0;
|
||||||
|
bench.run([&] {
|
||||||
|
key[0] = ++i;
|
||||||
|
acc *= MuHash3072(key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MuHashMul(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
MuHash3072 acc;
|
||||||
|
FastRandomContext rng(true);
|
||||||
|
MuHash3072 muhash{rng.randbytes(32)};
|
||||||
|
|
||||||
|
bench.run([&] {
|
||||||
|
acc *= muhash;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MuHashDiv(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
MuHash3072 acc;
|
||||||
|
FastRandomContext rng(true);
|
||||||
|
MuHash3072 muhash{rng.randbytes(32)};
|
||||||
|
|
||||||
|
for (size_t i = 0; i < bench.epochIterations(); ++i) {
|
||||||
|
acc *= muhash;
|
||||||
|
}
|
||||||
|
|
||||||
|
bench.run([&] {
|
||||||
|
acc /= muhash;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MuHashPrecompute(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
MuHash3072 acc;
|
||||||
|
FastRandomContext rng(true);
|
||||||
|
std::vector<unsigned char> key{rng.randbytes(32)};
|
||||||
|
|
||||||
|
bench.run([&] {
|
||||||
|
MuHash3072{key};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
BENCHMARK(RIPEMD160);
|
BENCHMARK(RIPEMD160);
|
||||||
BENCHMARK(SHA1);
|
BENCHMARK(SHA1);
|
||||||
BENCHMARK(SHA256);
|
BENCHMARK(SHA256);
|
||||||
|
@ -116,3 +165,8 @@ BENCHMARK(SipHash_32b);
|
||||||
BENCHMARK(SHA256D64_1024);
|
BENCHMARK(SHA256D64_1024);
|
||||||
BENCHMARK(FastRandom_32bit);
|
BENCHMARK(FastRandom_32bit);
|
||||||
BENCHMARK(FastRandom_1bit);
|
BENCHMARK(FastRandom_1bit);
|
||||||
|
|
||||||
|
BENCHMARK(MuHash);
|
||||||
|
BENCHMARK(MuHashMul);
|
||||||
|
BENCHMARK(MuHashDiv);
|
||||||
|
BENCHMARK(MuHashPrecompute);
|
||||||
|
|
Loading…
Add table
Reference in a new issue