Created
February 9, 2016 11:44
-
-
Save heikoheiko/0fa2b322560ba7794f22 to your computer and use it in GitHub Desktop.
Py Code for https://github.com/ethereum/wiki/wiki/Benchmarks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ethereum import trie, db, utils | |
import time | |
MIN_COUNT = 32 | |
ROUNDS = 1000 | |
ERA_SIZE = 4 | |
MAX_COUNT = 32 | |
SYMMETRIC = True | |
tests = [[3, 32, False], | |
[5, 32, False], | |
[9, 32, False], | |
[1000, 32, False], | |
[1000, 32, True]] | |
results = dict() | |
for i in range(100): | |
for ERA_SIZE, KEY_SIZE, SYMMETRIC in tests: | |
name = '1k-%d-%d-%s' % (ERA_SIZE, KEY_SIZE, 'mir' if SYMMETRIC else 'ran') | |
a = time.time() | |
t = trie.Trie(db.EphemDB()) | |
seed = '\x00' * 32 | |
for i in range(ROUNDS): | |
seed = utils.sha3(seed) | |
mykey = seed[:KEY_SIZE] | |
if SYMMETRIC: | |
t.update(mykey, mykey) | |
else: | |
seed = utils.sha3(seed) | |
myval = seed[-1] if ord(seed[0]) % 2 else seed | |
t.update(mykey, myval) | |
if i % ERA_SIZE == 0: | |
seed = t.root_hash | |
results[name] = min(results.get(name, 10000), int(1000 * (time.time() - a))) | |
# print t.root_hash.encode('hex') | |
print results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment