Gmod Vector can handle a string perfectly fine. and runs faster according to my benchmarks. It is slower than direct x,y,z Vector construction. But as you don't have that your function is much slower.
I don't even take into the double index of a global function. Or the fact that x, y and z are all global variables.
local function StringToVector(str)
local args = string.Split(str, " ")
local x = args[1]
local y = args[2]
local z = args[3]
return Vector(x, y, z)
end
local function StringToVecNoPass(str)
return Vector(str)
end
local gWareTime = 0
for x = 1, 1000 do
local start = SysTime()
StringToVector("1 2 3")
gWareTime = gWareTime + (SysTime() - start)
end
print("gWareTime: " .. gWareTime)
local gmodTime = 0
for x = 1, 1000 do
local start = SysTime()
StringToVecNoPass("1 2 3")
gmodTime = gmodTime + (SysTime() - start)
end
print("gmodTime: " .. gmodTime)
if gWareTime < gmodTime then
print("gWare is faster by a percentage " .. (gmodTime / gWareTime) * 100)
else
print("gmod is faster " .. (gWareTime / gmodTime) * 100)
end
Gmod Vector can handle a string perfectly fine. and runs faster according to my benchmarks. It is slower than direct x,y,z Vector construction. But as you don't have that your function is much slower.
I don't even take into the double index of a global function. Or the fact that x, y and z are all global variables.