]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Measure startup time
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 17 Jul 2016 02:40:04 +0000 (12:40 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 17 Jul 2016 02:40:36 +0000 (12:40 +1000)
qcsrc/common/models/model.qh
qcsrc/common/sounds/sound.qh
qcsrc/lib/static.qh

index 1c34a2547ee07117b1f52d5707bbebd3b1c80eae..91fb278ae0a5ec975c1580d4f7e023f8b96793e2 100644 (file)
@@ -19,7 +19,7 @@ CLASS(Model, Object)
             LOG_WARNINGF("Missing model: \"%s\"\n", s);
             return;
         }
             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)
         precache_model(s);
     }
 ENDCLASS(Model)
index b915062223918a81a7c0c8b90be3ac297054eca1..519f910b0d3fee4721a698c549a59316841d658b 100644 (file)
@@ -126,7 +126,7 @@ CLASS(Sound, Object)
            TC(Sound, this);
                string s = Sound_fixpath(this);
                if (!s) return;
            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)
                precache_sound(s);
        }
 ENDCLASS(Sound)
index e1cfeb8721ce54f6b29a9f440e410d2c29bf5626..6b5febe6fbfcab9909de383b4d7ccd86940474d6 100644 (file)
@@ -9,8 +9,23 @@ void __static_init_precache() {}
 void __shutdown() {}
 #define shutdownhooks() CALL_ACCUMULATED_FUNCTION(__shutdown)
 
 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) \
 #define _STATIC_INIT(where, func) \
-       void _static_##func(); \
+       [[accumulate]] void _static_##func() { profile(#func); } \
        ACCUMULATE_FUNCTION(where, _static_##func) \
        void _static_##func()
 
        ACCUMULATE_FUNCTION(where, _static_##func) \
        void _static_##func()