import time
def runtime(func):
def wrapper(*args,**kwargs):
start=time.perf_counter()
func(*args,**kwargs)
end =time.perf_counter()
print(end -start)
return wrapper
@runtime
def dubble_sort(L):
for i in range(1,len(L)):
for j in range(0,len(L)-i):
if L[j]>L[j+1]:
L[j],L[j+1]=L[j+1],L[j]
return L
if __name__ == '__main__':
array = [10, 17, 50, 7, 30, 24, 27, 45, 15, 5, 36, 21]
(dubble_sort(array))
网友评论