made test() a bit more friendly

This commit is contained in:
Vlad Zamfir 2014-07-13 19:34:14 +02:00
parent 4233cbbd2a
commit e545c62267
1 changed files with 10 additions and 5 deletions

View File

@ -59,8 +59,13 @@ def run_tape(v, tape):
return str(v) return str(v)
# This times the various parts of the hashing function - make the tape longer to make tape evaluation dominate # This times the various parts of the hashing function - you can make the tape longer to make tape evaluation dominate
def test(num_iterations, num_tape_evals, tape_w = 100, tape_d = 1000): #num_iterations is the number of tapes that are used
#num_tape_evals is the number of nonces allowed, per tape
#tape_w is the width of the tape
#tape_d is the depth of the tape
def test(num_iterations = 10, num_tape_evals = 1000, tape_w = 100, tape_d = 1000):
time_generating_tape = 0. time_generating_tape = 0.
time_generating_inputs = 0. time_generating_inputs = 0.
time_evaluating_tape = 0. time_evaluating_tape = 0.
@ -69,16 +74,16 @@ def test(num_iterations, num_tape_evals, tape_w = 100, tape_d = 1000):
t = time.time() t = time.time()
tape = gen_tape(str(i), tape_w, tape_d) tape = gen_tape(str(i), tape_w, tape_d)
time_generating_tape += time.time() - t time_generating_tape += time.time() - t
for j in xrange(num_tape_evals): for j in xrange(num_tape_evals):
t = time.time() t = time.time()
v = gen_inputs(str(j), tape_w) v = gen_inputs(str(j), tape_w)
time_generating_inputs += time.time() - t time_generating_inputs += time.time() - t
t = time.time() t = time.time()
x = run_tape(v,tape) x = run_tape(v,tape)
time_evaluating_tape += time.time() - t time_evaluating_tape += time.time() - t
t = time.time() t = time.time()
h = u.sha3(x) h = u.sha3(x)
time_sha_capping += time.time() - t time_sha_capping += time.time() - t