Skip to content

Interface: IXR_profiler ​

Lua script profiler namespace.

Since ​

OpenXRay 2025-03-19, ac4ba75d, PR #1771

Source ​

namespace profiler

Remarks ​

Requires an engine script profiler instance. Starting an already active profiler is ignored by the engine.

Methods ​

get_type() ​

ts
get_type(this: void): 0 | 1 | 2;

Parameters ​

ParameterType
thisvoid

Returns ​

0 | 1 | 2

Currently active profiler type.


is_active() ​

ts
is_active(this: void): boolean;

Parameters ​

ParameterType
thisvoid

Returns ​

boolean

Whether lua scripts profiler is active.


log_report() ​

Call Signature ​

ts
log_report(this: void): void;

Log report of profiler measurements in game console/log file. Use default engine limit to print top N entries.

Parameters ​
ParameterType
thisvoid
Returns ​

void

Call Signature ​

ts
log_report(this: void, entries_limit: number): void;

Log report of profiler measurements in game console/log file.

Parameters ​
ParameterTypeDescription
thisvoid-
entries_limitnumberLimit of top profiling entries to print.
Returns ​

void


reset() ​

ts
reset(this: void): void;

Reset measurements data of profiler.

Parameters ​

ParameterType
thisvoid

Returns ​

void

Remarks ​

Reset keeps the current profiling mode active and clears collected samples.


save_report() ​

ts
save_report(this: void): void;

Save report of profiler measurements in corresponding log/perf file.

Parameters ​

ParameterType
thisvoid

Returns ​

void

Remarks ​

Hook reports are saved under $logs$ as *_hook_profile.log. Sampling reports are saved as *_sampling_profile.perf.


start() ​

Call Signature ​

ts
start(this: void): void;

Start lua scripts profiler in default mode.

Parameters ​
ParameterType
thisvoid
Returns ​

void

Remarks ​

The default mode is hook profiling.

Call Signature ​

ts
start(this: void, profiler_type: TXR_ProfilerType): void;

Start lua scripts profiler of provided type.

Parameters ​
ParameterTypeDescription
thisvoid-
profiler_typeTXR_ProfilerTypeType of profiler to start (note: see global exports of type constants).
Returns ​

void

Remarks ​

Passing PROFILER_TYPE_NONE does not start profiling and only logs a message.


start_hook_mode() ​

ts
start_hook_mode(this: void): void;

Start profiler in hook mode. Profiling performance based on lua call start/end events.

Parameters ​

ParameterType
thisvoid

Returns ​

void

Remarks ​

Hook mode attaches a Lua hook. If another hook is already installed, start may fail and only log the failure.


start_sampling_mode() ​

Call Signature ​

ts
start_sampling_mode(this: void): void;

Start profiler in sampling mode with default sampling interval.

Parameters ​
ParameterType
thisvoid
Returns ​

void

Remarks ​

Sampling mode uses LuaJIT profiling. It cannot start when LuaJIT profiling is unavailable, for example with -nojit.

Call Signature ​

ts
start_sampling_mode(this: void, sampling_interval: number): void;

Start profiler in sampling mode with provided sampling interval value.

Parameters ​
ParameterTypeDescription
thisvoid-
sampling_intervalnumberInterval to collect samples with luaJIT sampling profiler.
Returns ​

void

Remarks ​

The engine clamps the interval to its supported range.


stop() ​

ts
stop(this: void): void;

Stop currently active profiler.

Parameters ​

ParameterType
thisvoid

Returns ​

void

Remarks ​

Stopping clears collected profiling data. Calling it while inactive only logs a message.