Java、Golang、NodeJS、Python冒泡排序速度对比
import time
def bubble_sort(unsorted):
for i in range(len(unsorted)-1):
for j in range(len(unsorted)-i-1):
if unsorted[j] > unsorted[j+1]:
unsorted[j],unsorted[j+1] = unsorted[j+1],unsorted[j]
return int(time.time()*1000)
startTime = int(time.time()*1000)
array = []
insideInt = 1000000
for i in range(10000):
array.append(insideInt-i*3)
stopTime = bubble_sort(array)
print("Use Time = ",stopTime-startTime)