mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-30 10:25:12 +02:00
Improved microbenchmarking with multiple features.
* inline performance critical code * Average runtime is specified and used to calculate iterations. * Console: show median of multiple runs * plot: show box plot * filter benchmarks * specify scaling factor * ignore src/test and src/bench in command line check script * number of iterations instead of time * Replaced runtime in BENCHMARK makro number of iterations. * Added -? to bench_bitcoin * Benchmark plotly.js URL, width, height can be customized * Fixed incorrect precision warning
This commit is contained in:
@@ -46,9 +46,9 @@ static void SHA256_32b(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(32,0);
|
||||
while (state.KeepRunning()) {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
CSHA256().Write(in.data(), in.size()).Finalize(in.data());
|
||||
}
|
||||
CSHA256()
|
||||
.Write(in.data(), in.size())
|
||||
.Finalize(in.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +63,9 @@ static void SHA512(benchmark::State& state)
|
||||
static void SipHash_32b(benchmark::State& state)
|
||||
{
|
||||
uint256 x;
|
||||
uint64_t k1 = 0;
|
||||
while (state.KeepRunning()) {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
*((uint64_t*)x.begin()) = SipHashUint256(0, i, x);
|
||||
}
|
||||
*((uint64_t*)x.begin()) = SipHashUint256(0, ++k1, x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +74,7 @@ static void FastRandom_32bit(benchmark::State& state)
|
||||
FastRandomContext rng(true);
|
||||
uint32_t x = 0;
|
||||
while (state.KeepRunning()) {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
x += rng.rand32();
|
||||
}
|
||||
x += rng.rand32();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,18 +83,16 @@ static void FastRandom_1bit(benchmark::State& state)
|
||||
FastRandomContext rng(true);
|
||||
uint32_t x = 0;
|
||||
while (state.KeepRunning()) {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
x += rng.randbool();
|
||||
}
|
||||
x += rng.randbool();
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(RIPEMD160);
|
||||
BENCHMARK(SHA1);
|
||||
BENCHMARK(SHA256);
|
||||
BENCHMARK(SHA512);
|
||||
BENCHMARK(RIPEMD160, 440);
|
||||
BENCHMARK(SHA1, 570);
|
||||
BENCHMARK(SHA256, 340);
|
||||
BENCHMARK(SHA512, 330);
|
||||
|
||||
BENCHMARK(SHA256_32b);
|
||||
BENCHMARK(SipHash_32b);
|
||||
BENCHMARK(FastRandom_32bit);
|
||||
BENCHMARK(FastRandom_1bit);
|
||||
BENCHMARK(SHA256_32b, 4700 * 1000);
|
||||
BENCHMARK(SipHash_32b, 40 * 1000 * 1000);
|
||||
BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000);
|
||||
BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user