From e86a60e6c7475819f99bb042793a7ad568368e2f Mon Sep 17 00:00:00 2001 From: aura Date: Sun, 26 Jul 2026 02:09:41 +0200 Subject: better prop system + profiler trace --- src/util/profiler.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/util/profiler.h') diff --git a/src/util/profiler.h b/src/util/profiler.h index 7caac96..334ad62 100644 --- a/src/util/profiler.h +++ b/src/util/profiler.h @@ -4,6 +4,7 @@ #include "allocator.h" #include "time.h" #include "thread.h" +#include "mem.h" #include "fnv.h" static THREAD_MUTEX __profiler_intern_mutex; @@ -13,7 +14,7 @@ static THREAD_MUTEX __profiler_intern_mutex; #endif #define PROFILE( x ) \ - PROFILER_LIST_ENTRY* __profiler_intern_id = __profiler_intern_start( x ); \ + PROFILER_LIST_ENTRY* __profiler_intern_id = __profiler_intern_start( x, (U64)__cur_retaddr() ); \ defer( { __profiler_intern_end( __profiler_intern_id ); } ) #define _profiled PROFILE( __func__ ); @@ -24,6 +25,7 @@ struct PROFILER_LIST_ENTRY { const char* name; U64 duration; U64 start; + U64 ptr; FNV1A hash; PROFILER_LIST_ENTRY* parent; @@ -76,7 +78,7 @@ inline void __profiler_intern_new_frame( PROFILER_LIST_ENTRY* entry ) { } } -inline PROFILER_LIST_ENTRY* __profiler_intern_start( const char* name ) { +inline PROFILER_LIST_ENTRY* __profiler_intern_start( const char* name, U64 ptr ) { PROFILER_LIST_ENTRY e; FNV1A fnv = fnv1a( name ); U64 tick = u_tick(); @@ -100,6 +102,7 @@ inline PROFILER_LIST_ENTRY* __profiler_intern_start( const char* name ) { e.children = {}; e.parent = gprof.current; e.hash = fnv; + e.ptr = ptr; if( gprof.current ) ep = gprof.current->children.push( e ); @@ -124,14 +127,25 @@ inline void __profiler_intern_init() { thread_mutex_init( &__profiler_intern_mutex ); } +inline void __profiler_intern_trace() { + thread_mutex_lock( &__profiler_intern_mutex ); + PROFILER_LIST_ENTRY* entry = gprof.current; + dlog( "======== [ profiler trace ] ==========\n" ); + while( entry ) { + dlog( "%s [0x%llx]\n", entry->name, entry->ptr ); + } +} + extern void __profiler_intern_draw_overlay( struct GL_FONT* font ); #define profiler_init() __profiler_intern_init() #define profiler_draw_tree( font ) __profiler_intern_draw_overlay( font ) +#define profiler_trace() __profiler_intern_trace() #else #define PROFILE( x ) #define _profiled +#define profiler_trace() #define profiler_init() #define profiler_draw_tree( x ) #endif -- cgit v1.2.3