From 3670af5a31b0810cce9a5f1f4c78158b4914e8db Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 16 Apr 2021 00:38:34 +0300 Subject: [PATCH] Fix incorrect values caused by outdated use of timing functions in perfstats 3 --- src/lua_hooklib.c | 2 +- src/m_perfstats.c | 4 ++-- src/m_perfstats.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 637809fd8..1665e36b0 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -473,7 +473,7 @@ void LUAh_ThinkFrame(void) hook_p hookp; // variables used by perf stats int hook_index = 0; - int time_taken = 0; + precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 1596a87e5..b58599b6d 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -62,7 +62,7 @@ int thinkframe_hooks_capacity = 16; static INT32 draw_row; -void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src) +void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) { if (!thinkframe_hooks) { @@ -565,7 +565,7 @@ void M_DrawPerfStats(void) len = (int)strlen(str); if (len > 20) str += len - 20; - snprintf(s, sizeof s - 1, "%20s: %u", str, thinkframe_hooks[i].time_taken); + snprintf(s, sizeof s - 1, "%20s: %d", str, I_PreciseToMicros(thinkframe_hooks[i].time_taken)); V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); y += 4; // repeated code! if (y > 192) diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 132bea38c..1ca71957f 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -30,11 +30,11 @@ extern int ps_lua_mobjhooks; typedef struct { - UINT32 time_taken; + precise_t time_taken; char short_src[LUA_IDSIZE]; } ps_hookinfo_t; -void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src); +void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); void M_DrawPerfStats(void);