Skip to content

Instantly share code, notes, and snippets.

@hymkor
Created October 16, 2014 01:06
Show Gist options
  • Save hymkor/253351abeb5080d1f36b to your computer and use it in GitHub Desktop.
Save hymkor/253351abeb5080d1f36b to your computer and use it in GitHub Desktop.
[Lua] rawset は別に速くなかった ref: http://qiita.com/zetamatta/items/9c2d70c32cfe47e08abe
::rem:: --[[ vim:set ft=lua:
@lua "%~f0" %* & exit /b
]]--
t = {}
for i=1,100000 do
table.insert(t,"x")
end
print(os.clock())
::rem:: --[[ vim:set ft=lua:
@lua "%~f0" %* & exit /b
]]--
t = {}
for i=1,100000 do
t[i] = "x"
end
print(os.clock())
::rem:: --[[ vim:set ft=lua:
@lua "%~f0" %* & exit /b
]]--
t = {}
for i=1,100000 do
rawset(t,i,"x")
end
print(os.clock())
$ bench1
0.018
$ bench2
0.006
$ bench3
0.015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment