test_pipline.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import redis
import time
r = redis.StrictRedis(host='localhost', port=6379, db=0)
#Cas normal
start = time.time()
for key in range(1000):
r.get(key)
stop = time.time()
print stop - start
#Lorsque le revêtement de tuyau
start = time.time()
with r.pipeline() as pipe:
for key in range(1000):
pipe.get(key)
pipe.execute()
stop = time.time()
print stop - start
Résultat de l'exécution: % python test_pipline.py 0.168359994888 0.0300588607788
Recommended Posts