Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created May 15, 2014 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YellowAfterlife/1c137cfc7ef97f4d1053 to your computer and use it in GitHub Desktop.
Save YellowAfterlife/1c137cfc7ef97f4d1053 to your computer and use it in GitHub Desktop.
--[[
1.118
1.411
5.35
]]--
function set_field(t, f, v)
t[f] = v
return v
end
local n = 10000000
local t = { }
local q
--
q = os.clock()
for i = 1, n do
t.one = i
t.two = t.one
end
print(os.clock() - q)
--
q = os.clock()
for i = 1, n do
t.two = set_field(t, 'one', i)
end
print(os.clock() - q)
--
q = os.clock()
for i = 1, n do
t.two = (function() t.one = i; return i end)()
end
print(os.clock() - q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment