added a benchmark

This commit is contained in:
Kjistóf 2017-12-02 00:00:41 +01:00
parent 921352c8d9
commit 85baa0d61f

24
benchmark.py Normal file
View File

@ -0,0 +1,24 @@
from proofow import pow256 as proofow
from time import perf_counter
def benchmark_pow(difficulty, iterations):
values = []
for i in range(iterations):
pw = proofow(difficulty)
values.append(measure(pw.work))
return sum(values) / len(values)
def measure(what):
start = perf_counter()
what()
return perf_counter() - start
if __name__ == '__main__':
ITER = 1000
print('Benchmarking proofow:\n')
for i in range(5):
print('{} iterations of difficuluty {} takes {} units of time'.format(ITER, i, benchmark_pow(i, ITER)*1000000))
print('\nYou should see that each difficulity level roughly doubles in terms of computation time.')