daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Apr 21st, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. from bigchaindb.core import Bigchain
  4. from bigchaindb.models import Transaction, Block
  5. from bigchaindb.common.crypto import generate_key_pair
  6. import time
  7.  
  8. test_size = int(sys.argv[1])
  9.  
  10.  
  11. priv, pub = generate_key_pair()
  12. b = Bigchain()
  13.  
  14. txs = []
  15.  
  16. prev_block = 'a'*64
  17.  
  18. def vote(block):
  19.     global prev_block
  20.     b.write_vote(b.vote(block.id, prev_block, True))
  21.     prev_block=block.id
  22.  
  23.  
  24.  
  25. for i in range(test_size):
  26.     tx = Transaction.create([pub], [([pub], i+1)])
  27.     block = b.create_block([tx])
  28.     b.write_block(block)
  29.     vote(block)
  30.     txs.append(tx)
  31.  
  32.  
  33. for create in txs:
  34.     tx = Transaction.transfer(create.to_inputs(), [([pub], 1)], create.id)
  35.     block = b.create_block([tx])
  36.     b.write_block(block)
  37.     vote(block)
  38.  
  39.  
  40. times = []
  41.  
  42. for i in range(10):
  43.     start = time.time()
  44.     outputs = b.get_outputs_filtered(pub, False)
  45.     t = time.time() - start
  46.     times.append(t)
  47.     print("%.2fms" % (t*1000))
  48.     assert len(outputs) == test_size
RAW Paste Data
Top