gherkin not so fast after all
Darn... tests prove otherwise.
I've tried the test myself. But shortened it a bit.
This is the testcode:
And these were my (somewhat more readable) results:
Note how marshel is the fastest for decoding, while cPicklehas the best overall performance.
If anyone is willing to extend this with any other modules. Like repr and unrepr, i surely would appreciate it.
I've tried the test myself. But shortened it a bit.
This is the testcode:
import time
def test(module):
t = time.clock()
s = module.dumps(value)
print module.__name__, 'encode', time.clock() - t, 'seconds', len(s), 'bytes'
t = time.clock()
module.loads(s)
print module.__name__, 'decode', time.clock() - t, 'seconds'
value = (("this is a record",1,2,1000001,"(08)123123123",
"some more text",22/7.0,
10123000000000234523454245234523452333333452145,
u"some unicode",True,False,None)*50000)
print 'repr(value) length ==',len(`value`)
import encoder, marshal, pickle, cPickle, json, xmlrpclib
test(encoder)
test(marshal)
test(pickle)
test(cPickle)
value = (("this is a record",1,2,1000001,"(08)123123123",
"some more text",22/7.0,1,0,None)*50000)
print 'without the long, boolean, and unicode. New data length is',
print 'represented:',len(`value`)
test(encoder)
test(marshal)
test(pickle)
test(cPickle)
test(json)
olddump = xmlrpclib.dumps
xmlrpclib.dumps = lambda x:olddump(x,allow_none=1)
test(xmlrpclib)
And these were my (somewhat more readable) results:
repr(value) length == 8800000
encoder encode 2.021 seconds 7450011 bytes
encoder decode 4.957 seconds
marshal encode 26.181 seconds 7000005 bytes
marshal decode 0.395 seconds
pickle encode 4.846 seconds 5300075 bytes
pickle decode 3.305 seconds
cPickle encode 1.125 seconds 5300075 bytes
cPickle decode 0.886 seconds
without the long, boolean, and unicode.
New data length is represented: 5100000
encoder encode 1.580 seconds 4650011 bytes
encoder decode 3.549 seconds
marshal encode 14.779 seconds 5200005 bytes
marshal decode 0.309 seconds
pickle encode 3.875 seconds 2550061 bytes
pickle decode 2.646 seconds
cPickle encode 0.559 seconds 2550061 bytes
cPickle decode 0.456 seconds
json encode 9.118 seconds 4350001 bytes
json decode 38.152 seconds
xmlrpclib encode 5.157 seconds 26500019 bytes
xmlrpclib decode 21.704 seconds
Note how marshel is the fastest for decoding, while cPicklehas the best overall performance.
If anyone is willing to extend this with any other modules. Like repr and unrepr, i surely would appreciate it.
<< Home