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
15 lines
284 B
Ruby
15 lines
284 B
Ruby
|
|
def reverse_list(list)
|
|
(list.length >> 1).times do |i|
|
|
last_index = list.length - i - 1
|
|
list[i], list[last_index] = list[last_index], list[i]
|
|
end
|
|
end
|
|
|
|
N = 20000000
|
|
list = (0...N).to_a
|
|
|
|
start = Time.now
|
|
reverse_list(list)
|
|
puts "elapsed: " + (Time.now - start).to_s + ' s'
|