3 #include "lib/macro.qh"
6 #define GETTIME_REALTIME 1
8 float(int tmr) _gettime = #67;
10 float(int tmr) _gettime = #519;
14 void profile(string s)
16 static float g_starttime;
17 float rt = _gettime(GETTIME_REALTIME);
18 if (!g_starttime) g_starttime = rt;
19 LOG_TRACEF("[%f] %s", rt - g_starttime, s);
22 #define _STATIC_INIT(func, where) \
23 ACCUMULATE void _static_##func##profile() { profile(#func); } \
24 ACCUMULATE_FUNCTION(where, _static_##func##profile) \
25 ACCUMULATE void _static_##func(); \
26 ACCUMULATE_FUNCTION(where, _static_##func) \
29 /** before worldspawn */
30 #define STATIC_INIT_EARLY(func) _STATIC_INIT(func##_0, __static_init_0)
31 #define static_init_early() CALL_ACCUMULATED_FUNCTION(__static_init_0)
32 void __static_init_0() {}
34 /** during worldspawn */
35 #define STATIC_INIT(func) _STATIC_INIT(func##_1, __static_init_1)
36 #define static_init() CALL_ACCUMULATED_FUNCTION(__static_init_1)
37 void __static_init_1() {}
39 /** directly after STATIC_INIT */
40 #define STATIC_INIT_LATE(func) _STATIC_INIT(func##_2, __static_init_2)
41 #define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_2)
42 void __static_init_2() {}
44 /** directly after STATIC_INIT_LATE */
45 #define PRECACHE(func) _STATIC_INIT(func##_3, __static_init_3)
46 #define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_3)
47 void __static_init_3() {}
49 /* other map entities spawn now */
51 /** before shutdown */
52 #define SHUTDOWN(func) _STATIC_INIT(func##_shutdown, __shutdown)
53 #define shutdownhooks() CALL_ACCUMULATED_FUNCTION( __shutdown)