pocketlang/tests/benchmarks/list/list.py
2021-06-24 11:16:51 +05:30

16 lines
349 B
Python

from time import process_time as clock
from math import floor
def reverse_list(list):
count = floor(len(list) / 2)
for i in range(count):
last_index = len(list) - i - 1
list[i], list[last_index] = list[last_index], list[i]
return list
start = clock()
N = 20000000
l = list(range(N))
reverse_list(l)
print('elapsed: ', clock() - start, 's')