KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Performance monitor

Code performance monitor More...

Files

file  perf_monitor.h
 Low-level performance monitor.
 

Data Structures

struct  perf_monitor
 /cond More...
 

Macros

#define __perf_monitor(f, l)
 
#define _perf_monitor(f, l)
 
#define __perf_monitor_if(f, l, tst)
 
#define _perf_monitor_if(f, l, tst)
 
#define perf_monitor()
 /endcond
 
#define perf_monitor_if(tst)
 Register a performance monitor for branch likeliness analysis.
 

Functions

void __stop_perf_monitor (struct perf_monitor **monitor)
 
struct perf_monitor__start_perf_monitor (struct perf_monitor *monitor)
 
void perf_monitor_init (perf_cntr_event_t event1, perf_cntr_event_t event2)
 Initialize the performance monitor system.
 
void perf_monitor_exit (void)
 De-initialize the performance monitor system.
 
void perf_monitor_print (FILE *f)
 Print statistics about the probe points to the given file descriptor.
 

Variables

const char * perf_monitor::fn
 
unsigned int perf_monitor::line
 
uint64_t perf_monitor::calls
 
uint64_t perf_monitor::time_ns
 
uint64_t perf_monitor::time_start
 
uint64_t perf_monitor::event0
 
uint64_t perf_monitor::event0_start
 
uint64_t perf_monitor::event1
 
uint64_t perf_monitor::event1_start
 

Detailed Description

Code performance monitor

The performance monitor API is built on top of the performance counter API, and as such cannot be used at the same time. With this API, programs can set probe points in different functional blocks and later obtain statistics about the execution of said functional blocks.

Macro Definition Documentation

◆ __perf_monitor

#define __perf_monitor ( f,
l )
Value:
static struct perf_monitor __perf_monitor_##l \
__attribute__((section(".monitors"))) = { f, l, }; \
struct perf_monitor *___perf_monitor_##l \
__attribute__((cleanup(__stop_perf_monitor))) = \
__start_perf_monitor(&__perf_monitor_##l)
void __stop_perf_monitor(struct perf_monitor **monitor)
/cond
Definition perf_monitor.h:41

◆ __perf_monitor_if

#define __perf_monitor_if ( f,
l,
tst )
Value:
({ \
static struct perf_monitor __perf_monitor_##l \
__attribute__((section(".monitors"))) = { f, l, }; \
__perf_monitor_##l.calls++; \
(tst) ? (__perf_monitor_##l.event1++,1) : (__perf_monitor_##l.event0++,0); \
})
uint64_t calls
Definition perf_monitor.h:44

◆ _perf_monitor

#define _perf_monitor ( f,
l )
Value:
#define __perf_monitor(f, l)
Definition perf_monitor.h:54

◆ _perf_monitor_if

#define _perf_monitor_if ( f,
l,
tst )
Value:
#define __perf_monitor_if(f, l, tst)
Definition perf_monitor.h:63

◆ perf_monitor

#define perf_monitor ( )
Value:
_perf_monitor(__func__, __LINE__)
#define _perf_monitor(f, l)
Definition perf_monitor.h:61

/endcond

Register a performance monitor in the current functional block

The performance monitor will run from the moment this macro is used, till the end of the functional block.

◆ perf_monitor_if

#define perf_monitor_if ( tst)
Value:
_perf_monitor_if(__func__, __LINE__, tst)
#define _perf_monitor_if(f, l, tst)
Definition perf_monitor.h:70

Register a performance monitor for branch likeliness analysis.

This macro is designed to be used inside an "if" expression, for instance: if (perf_monitor_if(!strcmp("test", str))) { ... }

The resulting performance monitor will measure the number of calls, and the number of times the branch was taken (in event1) and the number of time it was not (in event0).

Parameters
tstThe boolean expression that is normally used inside the "if" check

Function Documentation

◆ __start_perf_monitor()

struct perf_monitor * __start_perf_monitor ( struct perf_monitor * monitor)

◆ __stop_perf_monitor()

void __stop_perf_monitor ( struct perf_monitor ** monitor)

◆ perf_monitor_exit()

void perf_monitor_exit ( void )

De-initialize the performance monitor system.

After this function is called, the performance counter API can be used again.

◆ perf_monitor_init()

void perf_monitor_init ( perf_cntr_event_t event1,
perf_cntr_event_t event2 )

Initialize the performance monitor system.

Set up the performance monitor system. Note that using the performance monitor system will conflict with any external usage of the performance counter API.

Parameters
event1The first event mode (pef_cntr_event_t).
event2The second event mode (pef_cntr_event_t).

◆ perf_monitor_print()

void perf_monitor_print ( FILE * f)

Print statistics about the probe points to the given file descriptor.

Parameters
fA valid file descriptor to which the messages will be printed. Use "stdout" for the standard output.

Variable Documentation

◆ calls

uint64_t perf_monitor::calls

◆ event0

uint64_t perf_monitor::event0

◆ event0_start

uint64_t perf_monitor::event0_start

◆ event1

uint64_t perf_monitor::event1

◆ event1_start

uint64_t perf_monitor::event1_start

◆ fn

const char* perf_monitor::fn

◆ line

unsigned int perf_monitor::line

◆ time_ns

uint64_t perf_monitor::time_ns

◆ time_start

uint64_t perf_monitor::time_start