Skip to content

Instantly share code, notes, and snippets.

@gsalgado
Created August 23, 2018 05:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsalgado/afdd5ead5358e5023b2dbc5af76f2047 to your computer and use it in GitHub Desktop.
Save gsalgado/afdd5ead5358e5023b2dbc5af76f2047 to your computer and use it in GitHub Desktop.
profile make_trie_root_and_nodes()
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)
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)
@veox
Copy link

veox commented Aug 23, 2018

The two files are identical. Perhaps test_trie.py was uploaded by accident?..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment