mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
bench: Add SHA256 implementation specific benchmarks
This commit is contained in:
parent
5f72417176
commit
ce6df7df9b
1 changed files with 121 additions and 6 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <crypto/siphash.h>
|
#include <crypto/siphash.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
|
#include <tinyformat.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
|
||||||
/* Number of bytes to hash per iteration */
|
/* Number of bytes to hash per iteration */
|
||||||
|
@ -36,13 +37,48 @@ static void SHA1(benchmark::Bench& bench)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA256(benchmark::Bench& bench)
|
static void SHA256_STANDARD(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
|
||||||
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||||
bench.batch(in.size()).unit("byte").run([&] {
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
||||||
});
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256_SSE4(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
|
||||||
|
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||||
|
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256_AVX2(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
|
||||||
|
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||||
|
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256_SHANI(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
|
||||||
|
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||||
|
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA3_256_1M(benchmark::Bench& bench)
|
static void SHA3_256_1M(benchmark::Bench& bench)
|
||||||
|
@ -54,22 +90,92 @@ static void SHA3_256_1M(benchmark::Bench& bench)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA256_32b(benchmark::Bench& bench)
|
static void SHA256_32b_STANDARD(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
|
||||||
std::vector<uint8_t> in(32,0);
|
std::vector<uint8_t> in(32,0);
|
||||||
bench.batch(in.size()).unit("byte").run([&] {
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
CSHA256()
|
CSHA256()
|
||||||
.Write(in.data(), in.size())
|
.Write(in.data(), in.size())
|
||||||
.Finalize(in.data());
|
.Finalize(in.data());
|
||||||
});
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA256D64_1024(benchmark::Bench& bench)
|
static void SHA256_32b_SSE4(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
|
||||||
|
std::vector<uint8_t> in(32,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256()
|
||||||
|
.Write(in.data(), in.size())
|
||||||
|
.Finalize(in.data());
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256_32b_AVX2(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
|
||||||
|
std::vector<uint8_t> in(32,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256()
|
||||||
|
.Write(in.data(), in.size())
|
||||||
|
.Finalize(in.data());
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256_32b_SHANI(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
|
||||||
|
std::vector<uint8_t> in(32,0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
CSHA256()
|
||||||
|
.Write(in.data(), in.size())
|
||||||
|
.Finalize(in.data());
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256D64_1024_STANDARD(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
|
||||||
std::vector<uint8_t> in(64 * 1024, 0);
|
std::vector<uint8_t> in(64 * 1024, 0);
|
||||||
bench.batch(in.size()).unit("byte").run([&] {
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
SHA256D64(in.data(), in.data(), 1024);
|
SHA256D64(in.data(), in.data(), 1024);
|
||||||
});
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256D64_1024_SSE4(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
|
||||||
|
std::vector<uint8_t> in(64 * 1024, 0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
SHA256D64(in.data(), in.data(), 1024);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256D64_1024_AVX2(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
|
||||||
|
std::vector<uint8_t> in(64 * 1024, 0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
SHA256D64(in.data(), in.data(), 1024);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SHA256D64_1024_SHANI(benchmark::Bench& bench)
|
||||||
|
{
|
||||||
|
bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
|
||||||
|
std::vector<uint8_t> in(64 * 1024, 0);
|
||||||
|
bench.batch(in.size()).unit("byte").run([&] {
|
||||||
|
SHA256D64(in.data(), in.data(), 1024);
|
||||||
|
});
|
||||||
|
SHA256AutoDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA512(benchmark::Bench& bench)
|
static void SHA512(benchmark::Bench& bench)
|
||||||
|
@ -152,13 +258,22 @@ static void MuHashPrecompute(benchmark::Bench& bench)
|
||||||
|
|
||||||
BENCHMARK(BenchRIPEMD160, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(BenchRIPEMD160, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SHA1, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA1, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SHA256, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA256_STANDARD, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_SSE4, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_AVX2, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_SHANI, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SHA512, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA512, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SHA3_256_1M, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA3_256_1M, benchmark::PriorityLevel::HIGH);
|
||||||
|
|
||||||
BENCHMARK(SHA256_32b, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA256_32b_STANDARD, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_32b_SSE4, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_32b_AVX2, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256_32b_SHANI, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SipHash_32b, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SipHash_32b, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(SHA256D64_1024, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(SHA256D64_1024_STANDARD, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256D64_1024_SSE4, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256D64_1024_AVX2, benchmark::PriorityLevel::HIGH);
|
||||||
|
BENCHMARK(SHA256D64_1024_SHANI, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue