X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fstatic.qh;h=6b5febe6fbfcab9909de383b4d7ccd86940474d6;hb=0ae5c891a2dbe8e23f0d62b6121bfca904764de5;hp=e1cfeb8721ce54f6b29a9f440e410d2c29bf5626;hpb=724a41faf2cbfd86d41f3ab59ff8326a831a8326;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index e1cfeb872..6b5febe6f 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -9,8 +9,23 @@ void __static_init_precache() {} void __shutdown() {} #define shutdownhooks() CALL_ACCUMULATED_FUNCTION(__shutdown) +#define GETTIME_REALTIME 1 +#ifdef MENUQC +float(int tmr) _gettime = #67; +#else +float(int tmr) _gettime = #519; +#endif + +void profile(string s) +{ + static float g_starttime; + float rt = _gettime(GETTIME_REALTIME); + if (!g_starttime) g_starttime = rt; + LOG_TRACEF("[%f] %s", rt - g_starttime, s); +} + #define _STATIC_INIT(where, func) \ - void _static_##func(); \ + [[accumulate]] void _static_##func() { profile(#func); } \ ACCUMULATE_FUNCTION(where, _static_##func) \ void _static_##func()