Skip to content

Instantly share code, notes, and snippets.

@westhood
Created February 21, 2014 06:23
Show Gist options
  • Select an option

  • Save westhood/9129712 to your computer and use it in GitHub Desktop.

Select an option

Save westhood/9129712 to your computer and use it in GitHub Desktop.
local ffi = require "ffi"
local tick
local n = 8000
local x = {}
for i = 1, 8000 do
x[i] = i
end
local a = ffi.new("int64_t [?]", n)
tick = os.clock()
for i = 1, 8000 do
x[i] = i
end
print(os.clock() - tick)
tick = os.clock()
for i = 1, 8000 do
x[i] = a[i]
end
print(os.clock() - tick)
tick = os.clock()
for i = 1, 8000 do
x[i] = tonumber(a[i] + 1 - a[i])
end
print(os.clock() - tick)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment