mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Add DSHA256 and X11 benchmarks, refactor names of other algo benchmarks to group them together (#1925)
DSHA256 and X11 also have additional tests for data from 32 to 2048 bytes (for comparison, in steps)
This commit is contained in:
parent
4528c735f4
commit
0f4d963baf
@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2016 The Bitcoin Core developers
|
||||
// Copyright (c) 2018 The Dash Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@ -17,7 +18,7 @@
|
||||
/* Number of bytes to hash per iteration */
|
||||
static const uint64_t BUFFER_SIZE = 1000*1000;
|
||||
|
||||
static void RIPEMD160(benchmark::State& state)
|
||||
static void HASH_RIPEMD160(benchmark::State& state)
|
||||
{
|
||||
uint8_t hash[CRIPEMD160::OUTPUT_SIZE];
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
@ -25,7 +26,7 @@ static void RIPEMD160(benchmark::State& state)
|
||||
CRIPEMD160().Write(in.data(), in.size()).Finalize(hash);
|
||||
}
|
||||
|
||||
static void SHA1(benchmark::State& state)
|
||||
static void HASH_SHA1(benchmark::State& state)
|
||||
{
|
||||
uint8_t hash[CSHA1::OUTPUT_SIZE];
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
@ -33,7 +34,7 @@ static void SHA1(benchmark::State& state)
|
||||
CSHA1().Write(in.data(), in.size()).Finalize(hash);
|
||||
}
|
||||
|
||||
static void SHA256(benchmark::State& state)
|
||||
static void HASH_SHA256(benchmark::State& state)
|
||||
{
|
||||
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
@ -41,7 +42,7 @@ static void SHA256(benchmark::State& state)
|
||||
CSHA256().Write(in.data(), in.size()).Finalize(hash);
|
||||
}
|
||||
|
||||
static void SHA256_32b(benchmark::State& state)
|
||||
static void HASH_SHA256_0032b(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(32,0);
|
||||
while (state.KeepRunning()) {
|
||||
@ -51,7 +52,25 @@ static void SHA256_32b(benchmark::State& state)
|
||||
}
|
||||
}
|
||||
|
||||
static void SHA512(benchmark::State& state)
|
||||
static void HASH_DSHA256(benchmark::State& state)
|
||||
{
|
||||
uint8_t hash[CSHA256::OUTPUT_SIZE];
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(hash);
|
||||
}
|
||||
|
||||
static void HASH_DSHA256_0032b(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(32,0);
|
||||
while (state.KeepRunning()) {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void HASH_SHA512(benchmark::State& state)
|
||||
{
|
||||
uint8_t hash[CSHA512::OUTPUT_SIZE];
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
@ -59,7 +78,7 @@ static void SHA512(benchmark::State& state)
|
||||
CSHA512().Write(in.data(), in.size()).Finalize(hash);
|
||||
}
|
||||
|
||||
static void SipHash_32b(benchmark::State& state)
|
||||
static void HASH_SipHash_0032b(benchmark::State& state)
|
||||
{
|
||||
uint256 x;
|
||||
while (state.KeepRunning()) {
|
||||
@ -69,10 +88,124 @@ static void SipHash_32b(benchmark::State& state)
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(RIPEMD160);
|
||||
BENCHMARK(SHA1);
|
||||
BENCHMARK(SHA256);
|
||||
BENCHMARK(SHA512);
|
||||
static void HASH_DSHA256_0032b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(32,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
BENCHMARK(SHA256_32b);
|
||||
BENCHMARK(SipHash_32b);
|
||||
static void HASH_DSHA256_0080b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(80,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
static void HASH_DSHA256_0128b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(128,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
static void HASH_DSHA256_0512b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(512,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
static void HASH_DSHA256_1024b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(1024,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
static void HASH_DSHA256_2048b_single(benchmark::State& state)
|
||||
{
|
||||
std::vector<uint8_t> in(2048,0);
|
||||
while (state.KeepRunning())
|
||||
CHash256().Write(in.data(), in.size()).Finalize(&in[0]);
|
||||
}
|
||||
|
||||
static void HASH_X11(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(BUFFER_SIZE,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_0032b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(32,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_0080b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(80,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_0128b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(128,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_0512b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(512,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_1024b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(1024,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
static void HASH_X11_2048b_single(benchmark::State& state)
|
||||
{
|
||||
uint256 hash;
|
||||
std::vector<uint8_t> in(2048,0);
|
||||
while (state.KeepRunning())
|
||||
hash = HashX11(in.begin(), in.end());
|
||||
}
|
||||
|
||||
BENCHMARK(HASH_RIPEMD160);
|
||||
BENCHMARK(HASH_SHA1);
|
||||
BENCHMARK(HASH_SHA256);
|
||||
BENCHMARK(HASH_DSHA256);
|
||||
BENCHMARK(HASH_SHA512);
|
||||
BENCHMARK(HASH_X11);
|
||||
|
||||
BENCHMARK(HASH_SHA256_0032b);
|
||||
BENCHMARK(HASH_DSHA256_0032b);
|
||||
BENCHMARK(HASH_SipHash_0032b);
|
||||
|
||||
BENCHMARK(HASH_DSHA256_0032b_single);
|
||||
BENCHMARK(HASH_DSHA256_0080b_single);
|
||||
BENCHMARK(HASH_DSHA256_0128b_single);
|
||||
BENCHMARK(HASH_DSHA256_0512b_single);
|
||||
BENCHMARK(HASH_DSHA256_1024b_single);
|
||||
BENCHMARK(HASH_DSHA256_2048b_single);
|
||||
BENCHMARK(HASH_X11_0032b_single);
|
||||
BENCHMARK(HASH_X11_0080b_single);
|
||||
BENCHMARK(HASH_X11_0128b_single);
|
||||
BENCHMARK(HASH_X11_0512b_single);
|
||||
BENCHMARK(HASH_X11_1024b_single);
|
||||
BENCHMARK(HASH_X11_2048b_single);
|
||||
|
Loading…
Reference in New Issue
Block a user