From 4014a79bc852e6e92d9939f235c66edbfc3a9a1a Mon Sep 17 00:00:00 2001 From: Qi Zhou Date: Tue, 29 Oct 2019 15:37:44 -0700 Subject: [PATCH] add sha3 data perf test --- quarkchain/experimental/sha3_perf.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/quarkchain/experimental/sha3_perf.py b/quarkchain/experimental/sha3_perf.py index 56adb4667..1adbbb481 100644 --- a/quarkchain/experimental/sha3_perf.py +++ b/quarkchain/experimental/sha3_perf.py @@ -1,8 +1,8 @@ - # Performance of verification of transactions # # Some numbers on my machine (i7 7700K 4.2 GHZ): # SHA3 80000 shas/sec +# SHA3 514.86 Mb/s # One i7 4700K 3.5 GHZ): # SHA3 69000 shas/sec with pycryptodome. # SHA3 134000 shas/sec with pysha3. @@ -11,6 +11,9 @@ import argparse import time import profile +import os + +from quarkchain.utils import sha3_256 def test_perf(): @@ -24,6 +27,17 @@ def test_perf(): print("TPS: %.2f" % (N / duration)) +def test_perf_data(): + N = 100 + S = 1024 * 1024 + start_time = time.time() + b = os.urandom(S) + for i in range(N): + sha3_256(b) + duration = time.time() - start_time + print("Data per sec: %.2f Mb/s" % (N * S / 1024 / 1024 / duration)) + + def main(): parser = argparse.ArgumentParser() parser.add_argument("--profile", default=False) @@ -31,8 +45,10 @@ def main(): if args.profile: profile.run("test_perf()") + profile.run("test_perf_data()") else: test_perf() + test_perf_data() if __name__ == "__main__":