From a38884af99c5d53fb60a877400596dcba6b4114e Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 20 Aug 2026 21:33:50 +0300 Subject: [PATCH 1/2] Move chip cpu time calculation at the end of execution It seems that a significant part of lag from E2 chips is not tracked, this should make the CPU time calculation more accurate --- lua/entities/gmod_wire_expression2/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 00610311f9..170de2b912 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -175,7 +175,6 @@ function ENT:Execute(script, context) end end - context.time = context.time + (SysTime() - bench) context.stackdepth = context.stackdepth - 1 local forceTriggerOutputs = selfTbl.first or selfTbl.duped @@ -207,6 +206,8 @@ function ENT:Execute(script, context) end end + context.time = context.time + (SysTime() - bench) + if context.prfcount + context.prf - e2_softquota > e2_hardquota then local trace = context.trace self:Error("Expression 2 (" .. selfTbl.name .. "): tick quota exceeded (at line " .. trace.start_line .. ", char " .. trace.start_col .. ")", "hard quota exceeded") From c21152f92942094c82068f11c1a053babfccd123 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 20 Aug 2026 22:19:03 +0300 Subject: [PATCH 2/2] Account for events too --- lua/entities/gmod_wire_expression2/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 170de2b912..f14dfe0e45 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -230,6 +230,7 @@ function ENT:ExecuteEvent(evt, args) local handlers = selfTbl.registered_events[evt] if not handlers then return end + local bench = SysTime() self:PCallHook("preexecute") for name, handler in pairs(handlers) do @@ -239,7 +240,6 @@ function ENT:ExecuteEvent(evt, args) self:Error("Expression 2 (" .. selfTbl.name .. "): stack quota exceeded", "stack quota exceeded") end - local bench = SysTime() local ok, msg = pcall(handler, context, args) if not ok then @@ -259,7 +259,6 @@ function ENT:ExecuteEvent(evt, args) end end - context.time = context.time + (SysTime() - bench) context.stackdepth = context.stackdepth - 1 end @@ -277,6 +276,8 @@ function ENT:ExecuteEvent(evt, args) end end + context.time = context.time + (SysTime() - bench) + if context.prfcount + context.prf - e2_softquota > e2_hardquota then local trace = context.trace self:Error("Expression 2 (" .. selfTbl.name .. "): tick quota exceeded (at line " .. trace.start_line .. ", char " .. trace.start_col .. ")", "hard quota exceeded")