Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created Aug 11, 2014
Embed
What would you like to do?
measureparse.py
result = resp.content
if expect_json:
len_before = len(result)
t0=time.time()
result2 = ujson.loads(result)
t1=time.time()
result = json.loads(result)
t2=time.time()
with open('/tmp/parse.json.log', 'a') as f:
print >>f, "Took", '%.2f'%(1000 * (t2-t1)),
print >>f, "to parse", len_before, "bytes"
with open('/tmp/parse.ujson.log', 'a') as f:
print >>f, "Took", '%.2f'%(1000 * (t1-t0)),
print >>f, "to parse", len_before, "bytes"
if result != result2:
print "PLAIN"
print result
print "UJSON"
print result2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment