Guest User

http://stackoverflow.com/a/13241506/445073

a guest
Nov 6th, 2012
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import simplejson as json
  2. import msgpack
  3. import timeit
  4.  
  5. def test_json():
  6.     with open('test.json') as fh:
  7.         json.load(fh)
  8.  
  9. def test_msgpack():
  10.     with open('test.msgpack') as fh:
  11.         msgpack.load(fh)
  12.  
  13. if __name__ == "__main__":
  14.     for test in ('json', 'msgpack'):
  15.         print test,
  16.         print timeit.timeit(
  17.             '__main__.test_{0}()'.format(test),
  18.             setup='import __main__',
  19.             number=10000
  20.         )
Add Comment
Please, Sign In to add comment