[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_resume - lua_yieldk command counter readout?
- From: Flyer31 Test <flyer31@...>
- Date: Sun, 2 May 2021 18:18:17 +0200
I somehow always had problems in the last weeks in answering in this mailing list, but now it looks like it might work.
What about using a hook with a high count value and reading the hook count before and after your calls?
On 2021/4/14 22:47, Flyer31 Test wrote:
> Is it possible to readout the current value of this Lua command counter
in an easy way in C or Lua?
if by "command counter" you mean the number of VM instructions (or OPCODEs), the answer is no,
one obvious reason there no such API is because the VM is an "implementation detail", and as far
as I know, Lua does not keep track of it at all,
if you insist on using it, you must patch the VM and do it yourself, but I highly suggest against this idea,
and I don't think this counter would make much sense any way.
the VM OPCODEs are designed to be easily mapped to semantics of the Lua language, and easy to implement
efficiently. it is not meant to be used as performance measurement.
becase some of the OPCODEs represent very simple computations such as a single arithmetic addition,
or logical shift; while other OPCODEs might represent quite complex (thus
resource heavy) operations,
such as the generic `for` loop, or creating a closure; the counter of OPCODEs executed/interpreted
by the VM is meaningless for most users.