57#ifdef SBL_PROFILING_ENABLED
59 "CPU: avg=%d.%d%% peak=%d.%d%% overruns=%u\r\n",
60 static_cast<int>(budget.
avg_load() * 100.0f),
61 static_cast<int>(budget.
avg_load() * 1000.0f) % 10,
62 static_cast<int>(budget.
peak_load() * 100.0f),
63 static_cast<int>(budget.
peak_load() * 1000.0f) % 10,
66 if (n > 0 &&
static_cast<size_t>(pos) < size - 1) {
68 size_t remaining = size -
static_cast<size_t>(pos);
72 for (
size_t i = 0; i < n && static_cast<size_t>(pos) < size - 1; ++i) {
73 remaining = size -
static_cast<size_t>(pos);
77 remaining = size -
static_cast<size_t>(pos);
80 sections[i].name, sections[i].avg);
84 remaining = size -
static_cast<size_t>(pos);
91 (void)budget; (void)sections; (void)n;
92 if (size > 0) buf[0] =
'\0';
109#ifdef SBL_PROFILING_ENABLED
111 "#PROF cpu_avg=%d.%d cpu_peak=%d.%d cpu_min=%d.%d overruns=%u blocks=%u\r\n",
112 static_cast<int>(budget.
avg_load() * 100.0f),
113 static_cast<int>(budget.
avg_load() * 1000.0f) % 10,
114 static_cast<int>(budget.
peak_load() * 100.0f),
115 static_cast<int>(budget.
peak_load() * 1000.0f) % 10,
116 static_cast<int>(budget.
min_load() * 100.0f),
117 static_cast<int>(budget.
min_load() * 1000.0f) % 10,
121 for (
size_t i = 0; i < n && static_cast<size_t>(pos) < size - 1; ++i) {
122 size_t remaining = size -
static_cast<size_t>(pos);
124 "#PROF.%s cycles=%u\r\n",
125 sections[i].name, sections[i].avg);
130 (void)budget; (void)sections; (void)n;
131 if (size > 0) buf[0] =
'\0';
144#ifdef SBL_PROFILING_ENABLED
145 static const char* labels[] = {
146 "b0_10",
"b10_20",
"b20_30",
"b30_40",
"b40_50",
147 "b50_60",
"b60_70",
"b70_80",
"b80_90",
"b90_100",
"over"
152 for (
size_t i = 0; i < budget.
hist_size() &&
static_cast<size_t>(pos) < size - 1; ++i) {
153 size_t remaining = size -
static_cast<size_t>(pos);
158 if (
static_cast<size_t>(pos) < size - 1) {
159 size_t remaining = size -
static_cast<size_t>(pos);
166 if (size > 0) buf[0] =
'\0';
Audio callback cycle budget tracker.
float avg_load() const
Average CPU load as fraction [0.0, 1.0+].
uint32_t overruns() const
Number of callbacks that exceeded the cycle budget.
static constexpr size_t hist_size()
Number of histogram buckets.
float min_load() const
Minimum CPU load since last reset.
float peak_load() const
Peak (worst-case) CPU load since last reset.
uint32_t count() const
Total callbacks measured.
uint32_t hist_bucket(size_t i) const
Read histogram bucket count (0-indexed, last bucket is >100%)
int format(char *buf, size_t size, const char *fmt,...)
Format a string into a buffer (snprintf-style)
int format_tagged_report(char *buf, size_t size, const AudioBudget &budget, const NamedSection *sections, size_t n)
Format profiling data as tagged output lines.
int format_report(char *buf, size_t size, const AudioBudget &budget, const NamedSection *sections, size_t n)
Format a profiling report into a buffer.
int format_tagged_histogram(char *buf, size_t size, const AudioBudget &budget)
Format CPU load histogram as a tagged output line.