Python性能分析指南(4)

发表于:2013-11-12来源:开源中国社区作者:袁不语点击数: 标签:性能测试
print ? 01 from timer import Timer 02 from redis import Redis 03 rdb = Redis() 04 05 with Timer() as t: 06 rdb.lpush( foo , bar ) 07 print = elasped lpush: %s s % t.secs 08 09 with Timer as t: 10 rdb.
print?
01 from timer import Timer
02 from redis import Redis
03 rdb = Redis()
04  
05 with Timer() as t:
06     rdb.lpush("foo", "bar")
07 print "=> elasped lpush: %s s" % t.secs
08  
09 with Timer as t:
10     rdb.lpop("foo")

原文转自:http://www.oschina.net/translate/python-performance-analysis