Skip to content

Instantly share code, notes, and snippets.

@mocobeta
Created November 24, 2012 15:28
Show Gist options
  • Save mocobeta/4140135 to your computer and use it in GitHub Desktop.
Save mocobeta/4140135 to your computer and use it in GitHub Desktop.
KVS性能比較/データ
## memcached, Couchbase 両方で使用
import pylibmc
import md5
import time
host = 'host:port'
mc = pylibmc.Client([host])
ITEM_COUNT = 1000000
for i in range(0, ITEM_COUNT):
key = md5.new(str(i)).hexdigest()
val = key * 4
mc.set(key, val)
print 'Done.'
import pymongo
import md5
import time
host = 'host:port'
conn = pymongo.Connection([host])
db = conn.test
ITEM_COUNT = 1000000
for i in range(0, ITEM_COUNT):
key = md5.new(str(i)).hexdigest()
val = key * 4
data = {'_id': key, 'val': val}
db.mycoll.save(data, safe=True)
print 'Done.'
import redis
import md5
import time
host = 'host'
port = port
rc = redis.Redis(host, port)
ITEM_COUNT = 1000000
for i in range(0, ITEM_COUNT):
key = md5.new(str(i)).hexdigest()
val = key * 4
rc.set(key, val)
print 'Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment