Created
January 30, 2011 02:57
-
-
Save showyou/802471 to your computer and use it in GitHub Desktop.
This file contains 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
import msgpack | |
import time | |
from random import randint | |
start_time = time.time() | |
for i in xrange(1000000): | |
a = randint(1,1000) | |
b = randint(1,1000) | |
setdata = (a, b) | |
data = msgpack.packb(setdata) | |
#print data | |
result = msgpack.unpackb(data) | |
#print result | |
end_time = time.time() - start_time |
This file contains 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
from random import randint | |
start_time = time.time() | |
packer = msgpack.Packer() | |
for i in xrange(1000000): | |
a = randint(1,1000) | |
b = randint(1,1000) | |
setdata = (a, b) | |
data = packer.pack(setdata) | |
#print data | |
result = msgpack.unpackb(data) | |
#print result | |
end_time = time.time() - start_time | |
print "end_time", end_time |
This file contains 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 | |
import cPickle as pickle | |
import time | |
from random import randint | |
start_time = time.time() | |
for i in xrange(1000000): | |
a = randint(1,1000) | |
b = randint(1,1000) | |
setdata = (a, b) | |
data = pickle.dumps(setdata) | |
#print data | |
result = pickle.loads(data) | |
#print result | |
end_time = time.time() - start_time | |
print "end_time", end_time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
次。msgpacktime2.pyでも同じことやってみた。
cocona yuki% python msgpacktime2.py [
/gitrep/python/temp]/gitrep/python/temp]end_time 7.24350881577
cocona yuki% python msgpacktime2.py [
end_time 6.99837803841
cocona yuki% python msgpacktime2.py [
/gitrep/python/temp]/gitrep/python/temp]end_time 7.29973101616
cocona yuki% python msgpacktime2.py [
end_time 7.41284203529
cocona yuki% python msgpacktime2.py [~/gitrep/python/temp]
end_time 6.91521000862
やばい、これは早い