Skip to content

Instantly share code, notes, and snippets.

@stravant
Created August 15, 2021 20:23
Show Gist options
  • Save stravant/170f8c7ef07cc964e462ead88066ceaa to your computer and use it in GitHub Desktop.
Save stravant/170f8c7ef07cc964e462ead88066ceaa to your computer and use it in GitHub Desktop.
Showing the cost of not caching the upvalue
local upValueArray = {1}
return {
ParameterGenerator = function()
end;
Functions = {
["Empty loop"] = function()
for i = 1, 10000 do
end
end;
["Upvalue Noncached"] = function() -- You can change "Sample A" to a descriptive name for your function
for i = 1, 10000 do
local _ = upValueArray[1]
end
end;
["Upvalue Cached"] = function()
local cached = upValueArray
for i = 1, 10000 do
local _ = cached[1]
end
end;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment