Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created October 3, 2011 20:44
Show Gist options
  • Select an option

  • Save ericmoritz/1260188 to your computer and use it in GitHub Desktop.

Select an option

Save ericmoritz/1260188 to your computer and use it in GitHub Desktop.
LWWSet test
(env)Erics-MacBook-Pro:crdt eric$ python /tmp/millionkeys.py
Add:
0.573606014252
Serialize:
0.552729129791
Sort, Slice:
0.511281967163
Deserialize:
0.156991004944
import msgpack
from crdt.sets import LWWSet
from time import time
import json
NUM_KEYS = 1000000
s = LWWSet()
start = time()
for i in xrange(NUM_KEYS):
s.add(i)
print "Add:"
print time() - start
start = time()
x = msgpack.dumps(s.payload)
print "Serialize:"
print time() - start
start = time()
start_n = 100000
page = sorted(s.value)[start_n:start_n+25]
print "Sort, Slice:"
print time() - start
start = time()
news = LWWSet.from_payload(msgpack.loads(x))
print "Deserialize:"
print time() - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment