Profile image for Moriyosh Koizumi moriyoshi
Benchmark code for pytyrant and python-tokyotyrant
Language
Python
Tags
python tokyotyrant benchmark

Benchmark code for pytyrant and python-tokyotyrant

1 from cProfile import run 2 import tokyotyrant 3 from pytyrant import Tyrant 4 5 class PyTyrantTest(object): 6 def create_many(self): 7 data = 'a' * self.size 8 d = Tyrant.open('127.0.0.1', 1978) 9 for i in xrange(self.num_attr): 10 d.put("attr_%s" % i, data) 11 d.close() 12 13 def delete_all_stupid(self): 14 d = Tyrant.open('127.0.0.1', 1978) 15 for i in xrange(self.num_attr): 16 d.out("attr_%s" % i) 17 d.close() 18 19 def delete_all(self): 20 d = Tyrant.open('127.0.0.1', 1978) 21 d.vanish() 22 d.close() 23 24 class PyTokyoTyrantTest(object): 25 def create_many(self): 26 data = 'a' * self.size 27 d = tokyotyrant.open('127.0.0.1', 1978) 28 for i in xrange(self.num_attr): 29 d.put("attr_%s" % i, data) 30 d.close() 31 32 def delete_all_stupid(self): 33 d = tokyotyrant.open('127.0.0.1', 1978) 34 for i in xrange(self.num_attr): 35 d.out("attr_%s" % i) 36 d.close() 37 38 def delete_all(self): 39 d = tokyotyrant.open('127.0.0.1', 1978) 40 d.vanish() 41 d.close() 42 43 def doit(suite, **kwarg): 44 s = suite() 45 for k, v in kwarg.iteritems(): 46 setattr(s, k, v) 47 s.create_many() 48 s.delete_all_stupid() 49 s.create_many() 50 s.delete_all_stupid() 51 52 run('doit(PyTyrantTest, size=10, num_attr=10000)') 53 run('doit(PyTokyoTyrantTest, size=10, num_attr=10000)') 54 55 run('doit(PyTyrantTest, size=100, num_attr=50000)') 56 run('doit(PyTokyoTyrantTest, size=100, num_attr=50000)')

Discussion

Portion taken from http://github.com/didip/hail/raw/5490015047e6f533f8359e9097a3d90046b8ec94/profile_tests/tyrant_profile.py

pytyrant - http://code.google.com/p/pytyrant/ python-tokyotyrant - http://code.google.com/p/python-tokyotyrant/

Comments

Profile image for Martin Conte Reflejo 2010-01-24

By the way: You can try http://code.google.com/p/pyrant. It is a nice lib :)

Profile image for Ian Lewis IanLewis 2010-01-24

Yah, the code above is actually comparing the pure python pytyrant and the native code tokyotyrant libraries. See the "import pytyrant" line above :)