Skip to content

Commit

Permalink
add sha3 data perf test
Browse files Browse the repository at this point in the history
  • Loading branch information
qizhou committed Oct 29, 2019
1 parent 5310b34 commit 4014a79
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion quarkchain/experimental/sha3_perf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -11,6 +11,9 @@
import argparse
import time
import profile
import os

from quarkchain.utils import sha3_256


def test_perf():
Expand All @@ -24,15 +27,28 @@ 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)
args = parser.parse_args()

if args.profile:
profile.run("test_perf()")
profile.run("test_perf_data()")
else:
test_perf()
test_perf_data()


if __name__ == "__main__":
Expand Down

0 comments on commit 4014a79

Please sign in to comment.