So guys,
As I was coding yesterday, decided to create benchmearking handler for my spinner.
I want to set the sampling time in [ms]
function ENT:GetSpinCenter() if(SERVER) then return self:GetPhysicsObject():GetMassCenter() elseif(CLIENT) then return self:GetNWVector(gsSentHash.."_cen") end end function ENT:IsToggled() if(SERVER) then local oSent = self[gsSentHash]; return oSent.Togg elseif(CLIENT) then return self:GetNWBool(gsSentHash.."_togg") end end if(SERVER) then -- Represents the arguments of ENT:BroadCast() local gtBroadCast = { [1] = {"SetNWFloat", gsSentHash.."_power", 0}, [2] = {"SetNWFloat", gsSentHash.."_lever", 0} } -- Used for rate array output local gtRateMap = { [1] = {"bcTot", 1000}, [2] = {"bcTim", 1000}, [3] = {"eTick", 1000},
and display the amount of CPU time taken
https://github.com/dvdvideo1234/SpinnerTool/blob/master/lua/entities/sent_spinner.lua#L95 for all the calculations here:
oSent.IsERM = varRemoveER:GetBool() -- Whenever to remove the entity on error oSent.IsTDB = varEnableDT:GetBool() -- Enables the tick rate system array output oSent.Rate.isWDT = varEnableWT:GetBool() -- Translate SENT watchdog to an error oSent.Rate.bcTot = (varBroadCast:GetFloat() / 1000) -- Broadcast time sever-clients [ms] to [s] oSent.Rate.bcTim = (varBroadCast:GetFloat() / 1000) -- Broadcast compare value [ms] to [s] oSent.Rate.eTick = (varTickRate:GetFloat() / 1000) -- Entity ticking interval [ms] to [s] return self end function ENT:Setup(stSpinner) self:SetPhysRadius(stSpinner.Radi) -- Set the radius if given local oPhys = self:GetPhysicsObject() if(oPhys and oPhys:IsValid()) then self:SetToggled(stSpinner.Togg) -- Is it going to be toggled self:SetTorqueAxis(stSpinner.AxiL) -- Axis direction self:SetPower(stSpinner.Power) -- Torque amount self:SetTorqueLever(stSpinner.LevL, stSpinner.CLev) -- Lever direction and count self:SetLever(stSpinner.Lever) -- Leverage length self:SetNWVector(gsSentHash.."_cen", oPhys:GetMassCenter()) local oSent = self[gsSentHash] local nMass = math.Clamp(tonumber(stSpinner.Mass) or 1, 1, varMaxMass:GetFloat())
However it seems that the broadcasting event https://github.com/dvdvideo1234/SpinnerTool/blob/master/lua/entities/sent_spinner.lua#L257
does not trigger at 300 [ms] as expected.
Looks like the tame delta in [ms] is calculated wrong here:
function ENT:ApplyTweaks() local oSent = self[gsSentHash] oSent.IsERM = varRemoveER:GetBool() -- Whenever to remove the entity on error oSent.IsTDB = varEnableDT:GetBool() -- Enables the tick rate system array output oSent.Rate.isWDT = varEnableWT:GetBool() -- Translate SENT watchdog to an error oSent.Rate.bcTot = (varBroadCast:GetFloat() / 1000) -- Broadcast time sever-clients [ms] to [s] oSent.Rate.bcTim = (varBroadCast:GetFloat() / 1000) -- Broadcast compare value [ms] to [s] oSent.Rate.eTick = (varTickRate:GetFloat() / 1000) -- Entity ticking interval [ms] to [s] return self end function ENT:Setup(stSpinner) self:SetPhysRadius(stSpinner.Radi) -- Set the radius if given local oPhys = self:GetPhysicsObject() if(oPhys and oPhys:IsValid()) then self:SetToggled(stSpinner.Togg) -- Is it going to be toggled self:SetTorqueAxis(stSpinner.AxiL) -- Axis direction self:SetPower(stSpinner.Power) -- Torque amount self:SetTorqueLever(stSpinner.LevL, stSpinner.CLev) -- Lever direction and count self:SetLever(stSpinner.Lever) -- Leverage length
But when we see that SysTime() returns the time in seconds, so when I subtract seconds from seconds and multiply by 1000 to get the [ms] and the result is about (0.025),
which is quite small, considering the 300 [ms] for broadcast pass like 300 seconds …
Do any Ideas ?