mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-02-06 04:37:47 +08:00
b285336895
and the benchmark script refactored, and now it will generate an html report
21 lines
349 B
Lua
21 lines
349 B
Lua
local function reverse(arr)
|
|
local len = #arr
|
|
local max = math.floor(len / 2)
|
|
|
|
for i=1, max do
|
|
local idx = len + 1 - i
|
|
arr[i], arr[idx] = arr[idx], arr[i]
|
|
end
|
|
end
|
|
|
|
local N = 20000000
|
|
local list = {}
|
|
for i=1, N do
|
|
list[i] = i
|
|
end
|
|
|
|
local start = os.clock()
|
|
reverse(list)
|
|
local seconds = os.clock() - start
|
|
print('elapsed: ' .. seconds .. 's')
|