Created
April 14, 2011 17:31
-
-
Save j2labs/920006 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env python -u | |
| # python 3.2 | |
| # Starting json... done: 17.7406787872 | |
| # Starting simplejson... done: 6.82341694832 | |
| # Starting cjson... done: 2.29899692535 | |
| # Starting ujson... done: 0.729449987411 | |
| # Starting pickle... done: 45.2784938812 | |
| # Starting cPickle... done: 6.48070406914 | |
| import time | |
| import simplejson | |
| import json | |
| import cjson | |
| import ujson | |
| import pickle | |
| import cPickle | |
| cjson.dumps = cjson.encode | |
| cjson.loads = cjson.decode | |
| small_and_simple = { | |
| 'foo': 'bar', | |
| 'food': 'barf', | |
| 'good': 'bars', | |
| 'dood': 'wheres your car?', | |
| 'wheres your car': 'dude?', | |
| } | |
| mods = [json, simplejson, cjson, ujson, pickle, cPickle] | |
| for mod in mods: | |
| print 'Starting %s... ' % (mod.__name__), | |
| start = time.time() | |
| for i in xrange(1000000): | |
| mod.dumps(small_and_simple) | |
| print 'done:', time.time() - start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment