Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created August 11, 2014 17:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save peterbe/3dc9b066c154d13ba7c7 to your computer and use it in GitHub Desktop.
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