gmodWare / gware-utilities

gmodWare roleplay utilities
2 stars 1 forks source link

utils folder #21

Closed StarLight-Oliver closed 1 year ago

StarLight-Oliver commented 1 year ago

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
StarLight-Oliver commented 1 year ago

gWare.Utils.GetPlayerByNamePart appears to have a random debug print

MenschlichTv commented 1 year ago

gWare.Utils.GetPlayerByNamePart appears to have a random debug print

Fixed in d42a560e91ed16edd34d4ba476dcd43faccd9c9a

Icarussakka commented 1 year ago

done ty