Skip to content

Instantly share code, notes, and snippets.

@idning
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idning/03f43b6789f14e1fe878 to your computer and use it in GitHub Desktop.
Save idning/03f43b6789f14e1fe878 to your computer and use it in GitHub Desktop.
test_codis_mig.py
import threading
import os
import time
import commands
import redis
class RedisServer(threading.Thread):
def __init__(self, binary = 'redis-server', port = 7777):
threading.Thread.__init__(self)
self.binary = binary
self.port = port
def run(self):
cmd = '%s --port %s' % (self.binary, self.port)
print cmd
#os.system(cmd)
commands.getoutput(cmd)
def __str__(self):
return '%s:%s' % (self.binary, self.port)
r1 = RedisServer('./bin/codis-server', port = 7777)
r2 = RedisServer('./bin/codis-server', port = 7778)
r1.start()
r2.start()
time.sleep(1)
conn = redis.StrictRedis('127.0.0.1', r1.port)
i = 0
while i < 1000 * 1000:
conn.hmset('test-key', {'f-%s' % i: 1})
i += 1
t1 = time.time()
print conn.execute_command('slotsmgrttagone', '127.0.0.1', '7778', '1000', 'test-key')
t2 = time.time()
print t2 - t1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment