Created
January 1, 2016 09:23
-
-
Save ak64th/6d93039bb0d84af83643 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
# a benchmark script for gevent and redis-py | |
import gevent | |
from gevent import monkey | |
monkey.patch_all() | |
import timeit | |
import redis | |
import random | |
r = redis.StrictRedis(host='xxx', password='xxx') | |
r.flushall() | |
rand = random.Random() | |
zaddi = lambda i : r.zadd('ss', rand.randint(0,10000), i) | |
def mesure_me(): | |
redisgreenlets = [gevent.spawn(zaddi, i) for i in xrange(1000)] | |
gevent.joinall(redisgreenlets) | |
print(r.zrange('ss', 0, 10, True, True, int)) | |
timeit.Timer(stmt='mesure_me()',setup='from __main__ import mesure_me').timeit(number=10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment