Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
coreutil.h File Reference

Detailed Description

Design Philosophy

These are functions which can help profile code running on real hardware. They won't do anything useful in the emulator.

Usage

Call the functions as necessary.

Example

// Get the number of cycles when starting
uint32_t start = getCycleCount();
// Run some function to profile
some_long_func();
// Get the total number of cycles elapsed
uint32_t total = getCycleCount() - start;
// Print the number of cycles
printf("%" PRIu32 "\n", total);
STATIC uint32_t getCycleCount(void)
Get current cycle count of processor for profiling. It is in 1/F_CPU units. This will actually compil...
Definition coreutil.h:42

Go to the source code of this file.

Macros

#define STATIC   static
 Silly redefinition to trick Doxygen into documenting a static function, which it otherwise ignores.
 

Functions

STATIC uint32_t getCycleCount (void)
 Get current cycle count of processor for profiling. It is in 1/F_CPU units. This will actually compile down to be included in the code, itself, and "should" (does in all the tests I've run) execute in one clock cycle since there is no function call and rsr only takes one cycle to complete.
 

Macro Definition Documentation

◆ STATIC

#define STATIC   static

Silly redefinition to trick Doxygen into documenting a static function, which it otherwise ignores.

Function Documentation

◆ getCycleCount()

static uint32_t getCycleCount ( void )
inline

Get current cycle count of processor for profiling. It is in 1/F_CPU units. This will actually compile down to be included in the code, itself, and "should" (does in all the tests I've run) execute in one clock cycle since there is no function call and rsr only takes one cycle to complete.

Note, this will always return zero on for the emulator

Returns
Number of processor cycles on actual hardware, or zero in the emulator.