From 85baa0d61fd8cef828a08db45fc3f041f13ac9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 2 Dec 2017 00:00:41 +0100 Subject: [PATCH] added a benchmark --- benchmark.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 benchmark.py diff --git a/benchmark.py b/benchmark.py new file mode 100644 index 0000000..ea0908a --- /dev/null +++ b/benchmark.py @@ -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.')