标签:efault repeat and method als turn pre UNC pool
def timeit(stmt="pass", setup="pass", timer=default_timer, number=default_number, globals=None): """Convenience function to create Timer object and call timeit method.""" return Timer(stmt, setup, timer, globals).timeit(number) def repeat(stmt="pass", setup="pass", timer=default_timer, repeat=default_repeat, number=default_number, globals=None): """Convenience function to create Timer object and call repeat method.""" return Timer(stmt, setup, timer, globals).repeat(repeat, number)
两个都是生成了timer对象,然后调用timeit or repeat方法
其中如果setup为复合语句,则用 ; 隔开
import timeit
t = timeit.Timer("r.get(‘123‘)","import redis;pool = redis.ConnectionPool(host=‘127.0.0.1‘, port=6379, decode_responses=True);r = redis.Redis(connection_pool=pool)")
#使用分号对于多个
t.timeit(100)
标签:efault repeat and method als turn pre UNC pool
原文地址:https://www.cnblogs.com/yjybupt/p/11416470.html