Created
May 14, 2010 17:39
-
-
Save maxp/401412 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
#!/bin/env python | |
import memcache | |
import random | |
import time | |
mc = memcache.Client(["127.0.0.1:11211"]) | |
pc = {} | |
data = dict( a="abc", b=["def",123,('1','2')] ) | |
keys = [ "".join([random.choice('0123456789abcdef') for c in range(16)]) for k in range(10000) ] | |
def set_get_mc( key, data ): | |
mc.set( key, data ) | |
return mc.get(key) | |
def set_get_pc( key, data ): | |
pc[key] = data | |
return pc[key] | |
t0 = time.time() | |
for k in keys: | |
set_get_mc(k,data) | |
print "mc: ", time.time()-t0 | |
t0 = time.time() | |
for k in keys: | |
set_get_pc(k,data) | |
print "pc: ", time.time()-t0 | |
#. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment