performance_tests: add tests for new Cryptonight variants

This commit is contained in:
moneromooo-monero 2019-02-13 11:28:26 +00:00
parent fff23bf7c6
commit b9a618848f
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
2 changed files with 10 additions and 10 deletions

View File

@ -34,6 +34,7 @@
#include "crypto/crypto.h"
#include "cryptonote_basic/cryptonote_basic.h"
template<unsigned int variant>
class test_cn_slow_hash
{
public:
@ -42,18 +43,15 @@ public:
#pragma pack(push, 1)
struct data_t
{
char data[13];
char data[43];
};
#pragma pack(pop)
static_assert(13 == sizeof(data_t), "Invalid structure size");
static_assert(43 == sizeof(data_t), "Invalid structure size");
bool init()
{
if (!epee::string_tools::hex_to_pod("63617665617420656d70746f72", m_data))
return false;
if (!epee::string_tools::hex_to_pod("bbec2cacf69866a8e740380fe7b818fc78f8571221742d729d9d02d7f8989b87", m_expected_hash))
if (!epee::string_tools::hex_to_pod("63617665617420656d70746f763617665617420656d70746f72263617665617420656d70746f7201020304", m_data))
return false;
return true;
@ -62,11 +60,10 @@ public:
bool test()
{
crypto::hash hash;
crypto::cn_slow_hash(&m_data, sizeof(m_data), hash);
return hash == m_expected_hash;
crypto::cn_slow_hash(&m_data, sizeof(m_data), hash, variant);
return true;
}
private:
data_t m_data;
crypto::hash m_expected_hash;
};

View File

@ -193,7 +193,10 @@ int main(int argc, char** argv)
TEST_PERFORMANCE2(filter, p, test_wallet2_expand_subaddresses, 50, 200);
TEST_PERFORMANCE0(filter, p, test_cn_slow_hash);
TEST_PERFORMANCE1(filter, p, test_cn_slow_hash, 0);
TEST_PERFORMANCE1(filter, p, test_cn_slow_hash, 1);
TEST_PERFORMANCE1(filter, p, test_cn_slow_hash, 2);
TEST_PERFORMANCE1(filter, p, test_cn_slow_hash, 4);
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 32);
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 16384);