Created
August 15, 2021 20:23
-
-
Save stravant/170f8c7ef07cc964e462ead88066ceaa to your computer and use it in GitHub Desktop.
Showing the cost of not caching the upvalue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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