C++,python,热爱算法和机器学习
全部博文(1214)
分类: NOSQL
2016-05-26 20:00:46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/python2
import redis
import time
def without_pipeline():
r=redis.Redis()
for i in range(10000):
r.ping()
return
def with_pipeline():
r=redis.Redis()
pipeline=r.pipeline()
for i in range(10000):
pipeline.ping()
pipeline.execute()
return
def bench(desc):
start=time.clock()
desc()
stop=time.clock()
diff=stop-start
print "%s has token %s" % (desc.func_name,str(diff))
if __name__=='__main__':
bench(without_pipeline)
bench(with_pipeline)
|