Created
August 19, 2018 18:56
-
-
Save TinfoilHat0/639163679aba65b51c18f732f862b040 to your computer and use it in GitHub Desktop.
This file contains 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
# coding: utf-8 | |
import Savoir | |
import random | |
import string | |
from timeit import default_timer as timer | |
# All values must be in hex before stored in Multichain | |
def hexlify(s): | |
return s.encode().hex() | |
def unhexlify(s): | |
return bytes.fromhex(s).decode() | |
rpcuser='multichainrpc' | |
rpcpassword='CcSnnhc7bgeJdrWtVDxFKRYc56DG4ZXpuHFCEout71FD' | |
rpchost = 'localhost' | |
rpcport = '7200' | |
chainname = 'testchain' | |
api = Savoir.Savoir(rpcuser, rpcpassword, rpchost, rpcport, chainname) | |
streams = ['stream1','stream2','stream3','stream4','stream5','stream6','stream7'] | |
for s in streams: | |
api.create('stream', s, True) | |
api.subscribe(s) | |
size = 1000 | |
print('Loading...') | |
start = timer() | |
for _ in range(size): | |
key = ''.join([random.choice(string.ascii_letters) for _ in range(5)]) | |
val = hexlify(''.join([random.choice(string.ascii_letters) for _ in range(5)])) | |
for s in streams: | |
api.publish(s, key, val) | |
elapsed = timer()-start | |
print('Elapsed: ' + str(elapsed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment