Skip to content

Commit 7ddaa50

Browse files
committed
Add new profiler types. Add tracy types.
1 parent 9c526ae commit 7ddaa50

File tree

3 files changed

+161
-23
lines changed

3 files changed

+161
-23
lines changed

types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "./xr_lib/xr_luabind";
2020
import "./xr_lib/xr_map";
2121
import "./xr_lib/xr_math";
2222
import "./xr_lib/xr_multiplayer";
23+
import "./xr_lib/xr_profile";
2324
import "./xr_lib/xr_properties";
2425
import "./xr_lib/xr_relation";
2526
import "./xr_lib/xr_render";

types/xr_lib/xr_debug.d.ts

-23
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
declare module "xray16" {
2-
/**
3-
* @source C++ class profile_timer
4-
* @customConstructor profile_timer
5-
* @group xr_debug
6-
*/
7-
export class profile_timer extends EngineBinding {
8-
public constructor();
9-
public constructor(timer: profile_timer);
10-
11-
public stop(): void;
12-
13-
public start(): void;
14-
15-
public time(): f32;
16-
17-
/**
18-
* Overridden string cast is implemented for profiling timer.
19-
*
20-
* @returns serialized profile time.
21-
*/
22-
public toString(): string;
23-
}
24-
252
/**
263
* @source C++ class CConsole
274
* @customConstructor CConsole

types/xr_lib/xr_profile.d.ts

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
declare module "xray16" {
2+
export const PROFILER_TYPE_NONE: 0;
3+
export const PROFILER_TYPE_HOOK: 1;
4+
export const PROFILER_TYPE_SAMPLING: 2;
5+
6+
export type TXR_ProfilerType = typeof PROFILER_TYPE_NONE | typeof PROFILER_TYPE_HOOK | typeof PROFILER_TYPE_SAMPLING;
7+
8+
/**
9+
* @source C++ class profile_timer
10+
* @customConstructor profile_timer
11+
* @group xr_profile
12+
*/
13+
export class profile_timer extends EngineBinding {
14+
public constructor();
15+
public constructor(timer: profile_timer);
16+
17+
public stop(): void;
18+
19+
public start(): void;
20+
21+
public time(): f32;
22+
23+
/**
24+
* Overridden string cast is implemented for profiling timer.
25+
*
26+
* @returns serialized profile time.
27+
*/
28+
public toString(): string;
29+
}
30+
31+
/**
32+
* @source namespace profiler
33+
* @group xr_profile
34+
*/
35+
export interface IXR_profiler {
36+
/**
37+
* @returns whether lua scripts profiler is active
38+
*/
39+
is_active(this: void): boolean;
40+
41+
/**
42+
* @returns currently active profiler type
43+
*/
44+
get_type(this: void): typeof PROFILER_TYPE_NONE | typeof PROFILER_TYPE_HOOK | typeof PROFILER_TYPE_SAMPLING;
45+
46+
/**
47+
* Start lua scripts profiler in default mode.
48+
*/
49+
start(this: void): void;
50+
51+
/**
52+
* Start lua scripts profiler of provided type.
53+
*
54+
* @param profiler_type - type of profiler to start (note: see global exports of type constants)
55+
*/
56+
start(this: void, profiler_type: TXR_ProfilerType): void;
57+
58+
/**
59+
* Start profiler in hook mode.
60+
* Profiling performance based on lua call start/end events.
61+
*/
62+
start_hook_mode(this: void): void;
63+
64+
/**
65+
* Start profiler in sampling mode with default sampling interval.
66+
*/
67+
start_sampling_mode(this: void): void;
68+
69+
/**
70+
* Start profiler in sampling mode with provided sampling interval value.
71+
*
72+
* @param sampling_interval - interval to collect samples with luaJIT sampling profiler
73+
*/
74+
start_sampling_mode(this: void, sampling_interval: u32): void;
75+
76+
/**
77+
* Stop currently active profiler.
78+
*/
79+
stop(this: void): void;
80+
81+
/**
82+
* Reset measurements data of profiler.
83+
*/
84+
reset(this: void): void;
85+
86+
/**
87+
* Log report of profiler measurements in game console/log file.
88+
* Use default engine limit to print top N entries.
89+
*/
90+
log_report(this: void): void;
91+
92+
/**
93+
* Log report of profiler measurements in game console/log file.
94+
*
95+
* @param entries_limit - limit of top profiling entries to print
96+
*/
97+
log_report(this: void, entries_limit: u32): void;
98+
99+
/**
100+
* Save report of profiler measurements in corresponding log/perf file.
101+
*/
102+
save_report(this: void): void;
103+
}
104+
105+
/**
106+
* @group xr_profile
107+
*/
108+
export const profiler: IXR_profiler;
109+
110+
/**
111+
* @source namespace profiler
112+
* @group xr_profile
113+
*/
114+
export interface IXR_tracy {
115+
/**
116+
* Begin tracy profiling zone.
117+
*/
118+
ZoneBegin(this: void): void;
119+
120+
/**
121+
* Begin tracy profiling zone with defined name.
122+
*
123+
* @param name - name to display in tracy logs for current zone
124+
*/
125+
ZoneBeginN(this: void, name: string): void;
126+
127+
ZoneBeginS(this: void): void;
128+
129+
ZoneBeginNS(this: void): void;
130+
131+
/**
132+
* End tracy profiling zone.
133+
*/
134+
ZoneEnd(this: void): void;
135+
136+
/**
137+
* Set zone text.
138+
*
139+
* @param text - text description of the zone
140+
*/
141+
ZoneText(this: void, text: string): void;
142+
143+
/**
144+
* Set zone name on per-call basis.
145+
*
146+
* @param name - name of zone
147+
*/
148+
ZoneName(this: void, name: string): void;
149+
150+
/**
151+
* Send message to tracy profiler.
152+
*/
153+
Message(this: void): void;
154+
}
155+
156+
/**
157+
* @group xr_profile
158+
*/
159+
export const tracy: IXR_tracy;
160+
}

0 commit comments

Comments
 (0)