Created
October 18, 2021 17:03
-
-
Save howmanysmall/37dfd4ab5830096260ce5e8607dfb766 to your computer and use it in GitHub Desktop.
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 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