time.time()
을 두번써서 확인하면된다.
import time
start = time.time()
....
end = time.time()
print(end-start) # 단위: 초
for
vs map
for
vs reduce
생각한거랑 다르네.. 테스트가 잘못됬나?;
import time
k = 1000000
arr = [1] * k
a1 = time.time()
brr = [0] * k
for i in range(k):
brr[i] = i
a2 = time.time()
crr = []
for i in range(k):
crr.append(i)
a3 = time.time()
print(a2 - a1) # 0.04775595664978027
print(a3 - a2) # 0.03977394104003906