Browse Source

Benchmark a random equihash input.

pull/145/head
Taylor Hornby 8 years ago
parent
commit
722b0117d0
  1. 17
      src/zcbenchmarks.cpp

17
src/zcbenchmarks.cpp

@ -8,6 +8,8 @@
#include "crypto/equihash.h"
#include "chainparams.h"
#include "pow.h"
#include "sodium.h"
#include "streams.h"
#include "zcbenchmarks.h"
@ -101,11 +103,22 @@ double benchmark_verify_joinsplit(const CPourTx &joinsplit)
double benchmark_solve_equihash()
{
const char *testing = "testing";
CBlock pblock;
CEquihashInput I{pblock};
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << I;
Equihash eh {Params(CBaseChainParams::MAIN).EquihashN(), Params(CBaseChainParams::MAIN).EquihashK()};
crypto_generichash_blake2b_state eh_state;
eh.InitialiseState(eh_state);
crypto_generichash_blake2b_update(&eh_state, (const unsigned char*)testing, strlen(testing));
crypto_generichash_blake2b_update(&eh_state, (unsigned char*)&ss[0], ss.size());
uint256 nonce;
randombytes_buf(nonce.begin(), 32);
crypto_generichash_blake2b_update(&eh_state,
nonce.begin(),
nonce.size());
timer_start();
eh.BasicSolve(eh_state);
return timer_stop();

Loading…
Cancel
Save