Skip to content

Instantly share code, notes, and snippets.

@howmanysmall
Created October 18, 2021 17:03
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 howmanysmall/37dfd4ab5830096260ce5e8607dfb766 to your computer and use it in GitHub Desktop.
Save howmanysmall/37dfd4ab5830096260ce5e8607dfb766 to your computer and use it in GitHub Desktop.
local BoxMeta = {}
BoxMeta.__index = BoxMeta
function BoxMeta:get()
return self._value
end
function BoxMeta:set(v)
self._value = v
end
local function NewBoxMeta(v)
return setmetatable({_value = v}, BoxMeta)
end
local function Box(v)
local self = {}
self._value = v
function self:get()
return self._value
end
function self:set(v)
self._value = v
end
return self
end
local RUN = 1000
return {
ParameterGenerator = function()
-- This function is called before running your function (outside the timer)
-- and the return(s) are passed into your function arguments (after the Profiler). This sample
-- will pass the function a random number, but you can make it pass
-- arrays, Vector3s, or anything else you want to test your function on.
return math.random(1000, 100000)
end;
Functions = {
["Metatable"] = function(Profiler, RandomNumber)
local B = NewBoxMeta(RandomNumber)
for _ = 1, RUN do
B:set(B:get() / 2)
end
end;
["That"] = function(Profiler, RandomNumber)
local B = Box(RandomNumber)
for _ = 1, RUN do
B:set(B:get() / 2)
end
end;
-- You can add as many functions as you like!
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment