Created
August 19, 2018 18:49
-
-
Save TinfoilHat0/b806edb276e7003a77d4ebac53d5aad7 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 | |
# In[ ]: | |
import Savoir | |
import random | |
import string | |
from timeit import default_timer as timer | |
# In[ ]: | |
# 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() | |
# In[ ]: | |
rpcuser='multichainrpc' | |
rpcpassword='CcSnnhc7bgeJdrWtVDxFKRYc56DG4ZXpuHFCEout71FD' | |
rpchost = 'localhost' | |
rpcport = '7200' | |
chainname = 'testchain' | |
api = Savoir.Savoir(rpcuser, rpcpassword, rpchost, rpcport, chainname) | |
# In[ ]: | |
streams = ['stream1','stream2','stream3','stream4','stream5','stream6','stream7'] | |
for s in streams: | |
api.create('stream', s, True) | |
api.subscribe(s) | |
# In[ ]: | |
size = 1000 | |
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 | |
# In[ ]: | |
elapsed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment