added a benchmark
This commit is contained in:
parent
921352c8d9
commit
85baa0d61f
24
benchmark.py
Normal file
24
benchmark.py
Normal 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.')
|
Loading…
Reference in New Issue
Block a user