import timeit
def test():
lista = []
listb = []
for i in range(100):
lista.append(i)
for i in range(100):
listb.append(i)
return lista, listb
def test1():
a, b = test()
return len(a) == len(b) and sorted(a) == sorted(b)
T = timeit.timeit(stmt="test()", setup="from __main__ import test")
T1 = timeit.timeit(stmt="test1()", setup="from __main__ import test1")
print(T)
print(T1)
print(T1 - T)
python的性能测试(timeit)
猜你喜欢
转载自www.cnblogs.com/zhangzhaolin/p/12334781.html
今日推荐
周排行