pocketlang/tests/benchmarks/list/list.pk
Thakee Nathees 6a22653263 Minor code enhancements (read bellow)
- Warnings were fixed
- Libraries are registered internally when PKVM created
  and cleanedup when PKVM freed (if PK_NO_LIBS not defined)
- Lang.clock() moved to time module and sleep, epoch time
  were added.
- Support both upper case and lower case hex literals
- Support hex excaped characters inside strings (ex: "\x41")
- Native api for import modules added `pkImportModule(...)`
- pkAllocString, pkDeallocString are changed to pkRealloc.
- NewInstance, DeleteInstance functions now take PKVM however
  delete function should not allocate any memory since it's
  invoked at the GC execution.
2022-05-21 04:15:30 +05:30

22 lines
358 B
Plaintext

from time import clock
from math import floor
def reverse_list(list)
count = floor(list.length / 2)
for i in 0..count
last_index = list.length - i - 1
last = list[last_index]
list[last_index] = list[i]
list[i] = last
end
return list
end
N = 20000000
l = (0..N).as_list
start = clock()
reverse_list(l)
print('elapsed: ', clock() - start, 's')