File syn_profiler.h¶
FileList > debug > syn_profiler.h
Go to the source code of this file
Task profiler — CPU time tracking per scheduler task. More...
#include "../port/syn_port_system.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_ProfileEntry Per-task profile entry — timing stats and CPU usage. |
| struct | SYN_Profiler Task profiler instance. |
Public Types¶
| Type | Name |
|---|---|
| typedef void(* | SYN_ProfilerPrintFunc Print callback for profiler dump output. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_profiler_dump (const SYN_Profiler * prof, SYN_ProfilerPrintFunc print) Dump profiler results via print callback. |
| void | syn_profiler_enable (SYN_Profiler * prof, bool enable) Enable/disable profiling. |
| void | syn_profiler_init (SYN_Profiler * prof, SYN_ProfileEntry * entries, uint8_t capacity) Initialize the profiler. |
| void | syn_profiler_register (SYN_Profiler * prof, uint8_t index, const char * name) Register a task for profiling. |
| void | syn_profiler_task_begin (SYN_Profiler * prof, uint8_t index) Mark the start of a task's execution. |
| void | syn_profiler_task_end (SYN_Profiler * prof, uint8_t index) Mark the end of a task's execution. |
| void | syn_profiler_update (SYN_Profiler * prof) Update CPU percentages and reset counters for the next period. |
Public Static Functions¶
| Type | Name |
|---|---|
| const SYN_ProfileEntry * | syn_profiler_get (const SYN_Profiler * prof, uint8_t index) Get a profile entry (read-only). |
Detailed Description¶
Hooks into the scheduler to measure how much time each task consumes. Reports percentage, peak time, and call count.
** **
static SYN_ProfileEntry prof_entries[8];
static SYN_Profiler profiler;
syn_profiler_init(&profiler, prof_entries, 8);
// In scheduler loop (before/after each task run):
syn_profiler_task_begin(&profiler, task_index);
// ... run task ...
syn_profiler_task_end(&profiler, task_index);
// Periodically (e.g., every 1s):
syn_profiler_update(&profiler); // calculates percentages
syn_profiler_dump(&profiler, print_func);
Public Types Documentation¶
typedef SYN_ProfilerPrintFunc¶
Print callback for profiler dump output.
Parameters:
strNull-terminated string to output.
Public Functions Documentation¶
function syn_profiler_dump¶
Dump profiler results via print callback.
Parameters:
profProfiler.printPrint function.
function syn_profiler_enable¶
Enable/disable profiling.
Parameters:
profProfiler.enabletrue to enable, false to disable.
function syn_profiler_init¶
Initialize the profiler.
Parameters:
profProfiler instance.entriesArray of profile entries (one per task).capacityNumber of entries.
function syn_profiler_register¶
Register a task for profiling.
Parameters:
profProfiler.indexTask index (must match scheduler task index).nameTask name for display.
function syn_profiler_task_begin¶
Mark the start of a task's execution.
Parameters:
profProfiler.indexTask index.
function syn_profiler_task_end¶
Mark the end of a task's execution.
Parameters:
profProfiler.indexTask index.
function syn_profiler_update¶
Update CPU percentages and reset counters for the next period.
Call periodically (e.g., every 1 second).
Parameters:
profProfiler.
Public Static Functions Documentation¶
function syn_profiler_get¶
Get a profile entry (read-only).
static inline const SYN_ProfileEntry * syn_profiler_get (
const SYN_Profiler * prof,
uint8_t index
)
Parameters:
profProfiler.indexTask index.
Returns:
Profile entry, or NULL if index out of range.
The documentation for this class was generated from the following file src/syntropic/debug/syn_profiler.h