Created
August 23, 2018 05:40
-
-
Save gsalgado/afdd5ead5358e5023b2dbc5af76f2047 to your computer and use it in GitHub Desktop.
profile make_trie_root_and_nodes()
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
import cProfile | |
import os | |
import pstats | |
import random | |
import rlp | |
from eth.db.trie import make_trie_root_and_nodes | |
from eth.vm.forks.frontier.transactions import FrontierTransaction | |
def create_transactions(count): | |
transactions = [] | |
for i in range(count): | |
value = random.randint(0, 999) | |
data = os.urandom(32) | |
to = os.urandom(20) | |
v, r, s = random.randint(0, 999), random.randint(0, 999), random.randint(0, 999) | |
transactions.append(FrontierTransaction( | |
nonce=i, gas_price=123, gas=1234000, to=to, value=value, data=data, v=v, r=r, s=s)) | |
encoded = rlp.encode(transactions) | |
return rlp.decode( | |
encoded, sedes=rlp.sedes.CountableList(FrontierTransaction), recursive_cache=True) | |
def test_make_trie_root_and_nodes(): | |
profiler = cProfile.Profile() | |
transactions = create_transactions(10000) | |
profiler.enable() | |
make_trie_root_and_nodes(transactions) | |
profiler.disable() | |
stats = pstats.Stats(profiler) | |
stats.sort_stats('cumulative').print_stats(30) |
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
import cProfile | |
import os | |
import pstats | |
import random | |
import rlp | |
from eth.db.trie import make_trie_root_and_nodes | |
from eth.vm.forks.frontier.transactions import FrontierTransaction | |
def create_transactions(count): | |
transactions = [] | |
for i in range(count): | |
value = random.randint(0, 999) | |
data = os.urandom(32) | |
to = os.urandom(20) | |
v, r, s = random.randint(0, 999), random.randint(0, 999), random.randint(0, 999) | |
transactions.append(FrontierTransaction( | |
nonce=i, gas_price=123, gas=1234000, to=to, value=value, data=data, v=v, r=r, s=s)) | |
encoded = rlp.encode(transactions) | |
return rlp.decode( | |
encoded, sedes=rlp.sedes.CountableList(FrontierTransaction), recursive_cache=True) | |
def test_make_trie_root_and_nodes(): | |
profiler = cProfile.Profile() | |
transactions = create_transactions(10000) | |
profiler.enable() | |
make_trie_root_and_nodes(transactions) | |
profiler.disable() | |
stats = pstats.Stats(profiler) | |
stats.sort_stats('cumulative').print_stats(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The two files are identical. Perhaps
test_trie.py
was uploaded by accident?..