Skip to content

Commit 7b9bcf3

Browse files
committed
Shows the ops on the js chips overlay
1 parent 407692a commit 7b9bcf3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

c++_module/js.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,9 @@ LUA_FUNCTION( lua_eval ) {
26542654
}
26552655

26562656
//JSValue result = JS_Eval(contexts[context], script, length, "<stdin>", JS_EVAL_TYPE_GLOBAL);
2657+
26572658
set_ops(ctx, 0);
2659+
26582660
JSValue bytecode = JS_ReadObject(ctx, (uint8_t*)script, length, JS_READ_OBJ_BYTECODE);
26592661
JSValue result = JS_EvalFunction(ctx, bytecode);
26602662

@@ -2691,8 +2693,8 @@ LUA_FUNCTION( lua_get_ops ) {
26912693
return 2;
26922694
}
26932695

2696+
LUA->PushNumber(0);
26942697
LUA->PushNumber(get_ops(contexts[context]));
2695-
LUA->PushNil();
26962698

26972699
return 2;
26982700
}

wire-js-chip_2/lua/entities/gmod_wire_jschip.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ function ENT:Think()
2525
self:Error(result)
2626
end
2727
end
28+
29+
local err, ops = JS_GetOps(self.ctx)
30+
self:SetOverlayData({
31+
txt = "JS Chip\n\nLast Execution:\n" .. ops .. " ops, " .. math.Round((ops / 25000) * 100, 1) .. "%"
32+
})
2833

2934
self:NextThink( CurTime() )
3035
return true

0 commit comments

Comments
 (0)