dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
src
profiler.h
Go to the documentation of this file.
1
2
#ifndef PROFILER_H
3
#define PROFILER_H
4
8
9
#ifdef DSEKAI_PROFILER
10
11
#define PROFILE_FIELDS_STRUCT( field ) int32_t field;
12
13
struct
DSEKAI_PROFILE {
14
PROFILE_FIELDS( PROFILE_FIELDS_STRUCT );
15
};
16
17
static
struct
DSEKAI_PROFILE profile;
18
static
int32_t profile_diff = 0;
19
20
# define profiler_init() memory_zero_ptr( &profile, sizeof( struct DSEKAI_PROFILE ) )
21
# define profiler_set() profile_diff = graphics_get_ms(); if( 0 > profile_diff ) { error_printf( "error setting profiler!" ); }
22
# define profiler_incr( field ) if( 0 <= profile_diff ) { profile.field += (graphics_get_ms() - profile_diff); }
23
24
#define PROFILE_FIELDS_PRINTF( field ) debug_printf( 3, #field ": %d", profile.field );
25
26
# define profiler_print( profiler_module ) debug_printf( 3, "=== " profiler_module " PROFILER RESULTS ===" ); PROFILE_FIELDS( PROFILE_FIELDS_PRINTF ); debug_printf( 3, "=== END " profiler_module " PROFILER RESULTS ===" );
27
28
#else
29
30
# define profiler_print( profiler_module )
31
# define profiler_init()
32
# define profiler_set()
33
# define profiler_incr( field )
34
35
#endif
/* DSEKAI_PROFILER */
36
37
#endif
/* !PROFILER_H */
38
Generated by
1.13.2