Skip to content

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.

typedef void(* SYN_ProfilerPrintFunc) (const char *str);

Parameters:

  • str Null-terminated string to output.

Public Functions Documentation

function syn_profiler_dump

Dump profiler results via print callback.

void syn_profiler_dump (
    const SYN_Profiler * prof,
    SYN_ProfilerPrintFunc print
) 

Parameters:

  • prof Profiler.
  • print Print function.

function syn_profiler_enable

Enable/disable profiling.

void syn_profiler_enable (
    SYN_Profiler * prof,
    bool enable
) 

Parameters:

  • prof Profiler.
  • enable true to enable, false to disable.

function syn_profiler_init

Initialize the profiler.

void syn_profiler_init (
    SYN_Profiler * prof,
    SYN_ProfileEntry * entries,
    uint8_t capacity
) 

Parameters:

  • prof Profiler instance.
  • entries Array of profile entries (one per task).
  • capacity Number of entries.

function syn_profiler_register

Register a task for profiling.

void syn_profiler_register (
    SYN_Profiler * prof,
    uint8_t index,
    const char * name
) 

Parameters:

  • prof Profiler.
  • index Task index (must match scheduler task index).
  • name Task name for display.

function syn_profiler_task_begin

Mark the start of a task's execution.

void syn_profiler_task_begin (
    SYN_Profiler * prof,
    uint8_t index
) 

Parameters:

  • prof Profiler.
  • index Task index.

function syn_profiler_task_end

Mark the end of a task's execution.

void syn_profiler_task_end (
    SYN_Profiler * prof,
    uint8_t index
) 

Parameters:

  • prof Profiler.
  • index Task index.

function syn_profiler_update

Update CPU percentages and reset counters for the next period.

void syn_profiler_update (
    SYN_Profiler * prof
) 

Call periodically (e.g., every 1 second).

Parameters:

  • prof Profiler.

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:

  • prof Profiler.
  • index Task 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