mirror of
https://github.com/ultrajson/ultrajson.git
synced 2024-11-24 05:12:02 +01:00
- Updated benchmark
This commit is contained in:
parent
a52e423b63
commit
7ca3a78b8e
17
README
17
README
@ -1,3 +1,16 @@
|
||||
UltraJSON is a fast and extendable JSON encoder written in pure C
|
||||
Python bindings are available as the module ujson which currently supports the encode method
|
||||
UltraJSON is a fast and extendable JSON encoder and decoder written in pure C
|
||||
|
||||
Python bindings are available as the module ujson which currently supports the encode method.
|
||||
|
||||
|
||||
Encoder benchmarks:
|
||||
Preliminary benchmarks indicate this performance:
|
||||
ujson encode : 58061.68741 calls/sec
|
||||
simplejson encode : 19025.95344 calls/sec
|
||||
cjson encode : 15308.70966 calls/sec
|
||||
json encode : 2407.92068 calls/sec
|
||||
|
||||
See (python/benchmark.py) for further information.
|
||||
|
||||
NOTE: These benchmarks are preliminary!
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
import simplejson
|
||||
import ujson
|
||||
import json
|
||||
import cjson
|
||||
import time
|
||||
|
||||
user = { "userId": 3381293, "username": "johndoe", "fullname": u"John Doe the Second", "isAuthorized": True, "approval": 31.1471, "jobs": [], "currJob": None }
|
||||
@ -15,11 +16,18 @@ def simplejsonEnc():
|
||||
x = simplejson.dumps(testObject)
|
||||
|
||||
def jsonEnc():
|
||||
x = simplejson.dumps(testObject)
|
||||
x = json.dumps(testObject)
|
||||
|
||||
def cjsonEnc():
|
||||
x = cjson.encode(testObject)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import timeit
|
||||
print "ujson encode : ", timeit.repeat("ujsonEnc()", "from __main__ import ujsonEnc", time.clock, 3, 100000)
|
||||
print "simplejson encode: ", timeit.repeat("simplejsonEnc()", "from __main__ import simplejsonEnc", time.clock, 3, 100000)
|
||||
print "json encode : ", timeit.repeat("jsonEnc()", "from __main__ import jsonEnc", time.clock, 3, 100000)
|
||||
|
||||
COUNT = 10000
|
||||
|
||||
print "ujson encode : %.05f calls/sec" % (COUNT / min(timeit.repeat("ujsonEnc()", "from __main__ import ujsonEnc", time.clock, 5, COUNT)), )
|
||||
print "simplejson encode : %.05f calls/sec" % (COUNT / min(timeit.repeat("simplejsonEnc()", "from __main__ import simplejsonEnc", time.clock, 5, COUNT)), )
|
||||
print "cjson encode : %.05f calls/sec" % (COUNT / min(timeit.repeat("cjsonEnc()", "from __main__ import cjsonEnc", time.clock, 5, COUNT)), )
|
||||
print "json encode : %.05f calls/sec" % (COUNT / min(timeit.repeat("jsonEnc()", "from __main__ import jsonEnc", time.clock, 5, COUNT)), )
|
||||
|
Loading…
Reference in New Issue
Block a user