From: TimePath Date: Sun, 17 Jul 2016 02:40:04 +0000 (+1000) Subject: Measure startup time X-Git-Tag: xonotic-v0.8.2~700^2~64 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=ad7be281f504399fb46e3f5dd6393f221b4154cb Measure startup time --- diff --git a/qcsrc/common/models/model.qh b/qcsrc/common/models/model.qh index 1c34a2547e..91fb278ae0 100644 --- a/qcsrc/common/models/model.qh +++ b/qcsrc/common/models/model.qh @@ -19,7 +19,7 @@ CLASS(Model, Object) LOG_WARNINGF("Missing model: \"%s\"\n", s); return; } - LOG_DEBUGF("precache_model(\"%s\")\n", s); + profile(sprintf("precache_model(\"%s\")\n", s)); precache_model(s); } ENDCLASS(Model) diff --git a/qcsrc/common/sounds/sound.qh b/qcsrc/common/sounds/sound.qh index b915062223..519f910b0d 100644 --- a/qcsrc/common/sounds/sound.qh +++ b/qcsrc/common/sounds/sound.qh @@ -126,7 +126,7 @@ CLASS(Sound, Object) TC(Sound, this); string s = Sound_fixpath(this); if (!s) return; - LOG_DEBUGF("precache_sound(\"%s\")\n", s); + profile(sprintf("precache_sound(\"%s\")\n", s)); precache_sound(s); } ENDCLASS(Sound) diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index e1cfeb8721..6b5febe6fb 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()