32#ifndef SBL_COMMON_DIAGNOSTICS_REPORT_HPP_
33#define SBL_COMMON_DIAGNOSTICS_REPORT_HPP_
59#ifdef SBL_PROFILING_ENABLED
61 "CPU: avg=%d.%d%% peak=%d.%d%% overruns=%u\r\n",
62 static_cast<int>(budget.
avg_load() * 100.0f),
63 static_cast<int>(budget.
avg_load() * 1000.0f) % 10,
64 static_cast<int>(budget.
peak_load() * 100.0f),
65 static_cast<int>(budget.
peak_load() * 1000.0f) % 10,
68 if (n > 0 &&
static_cast<size_t>(pos) < size - 1) {
70 size_t remaining = size -
static_cast<size_t>(pos);
74 for (
size_t i = 0; i < n && static_cast<size_t>(pos) < size - 1; ++i) {
75 remaining = size -
static_cast<size_t>(pos);
79 remaining = size -
static_cast<size_t>(pos);
82 sections[i].name, sections[i].avg);
86 remaining = size -
static_cast<size_t>(pos);
93 (void)budget; (void)sections; (void)n;
94 if (size > 0) buf[0] =
'\0';
111#ifdef SBL_PROFILING_ENABLED
113 "#PROF cpu_avg=%d.%d cpu_peak=%d.%d cpu_min=%d.%d overruns=%u blocks=%u\r\n",
114 static_cast<int>(budget.
avg_load() * 100.0f),
115 static_cast<int>(budget.
avg_load() * 1000.0f) % 10,
116 static_cast<int>(budget.
peak_load() * 100.0f),
117 static_cast<int>(budget.
peak_load() * 1000.0f) % 10,
118 static_cast<int>(budget.
min_load() * 100.0f),
119 static_cast<int>(budget.
min_load() * 1000.0f) % 10,
123 for (
size_t i = 0; i < n && static_cast<size_t>(pos) < size - 1; ++i) {
124 size_t remaining = size -
static_cast<size_t>(pos);
126 "#PROF.%s ticks=%u\r\n",
127 sections[i].name, sections[i].avg);
132 (void)budget; (void)sections; (void)n;
133 if (size > 0) buf[0] =
'\0';
146#ifdef SBL_PROFILING_ENABLED
147 static const char* labels[] = {
148 "b0_10",
"b10_20",
"b20_30",
"b30_40",
"b40_50",
149 "b50_60",
"b60_70",
"b70_80",
"b80_90",
"b90_100",
"over"
154 for (
size_t i = 0; i < budget.
hist_size() &&
static_cast<size_t>(pos) < size - 1; ++i) {
155 size_t remaining = size -
static_cast<size_t>(pos);
160 if (
static_cast<size_t>(pos) < size - 1) {
161 size_t remaining = size -
static_cast<size_t>(pos);
168 if (size > 0) buf[0] =
'\0';
Audio callback tick budget tracker.
uint32_t overruns() const
Number of callbacks that exceeded the tick budget.
static constexpr size_t hist_size()
Number of histogram buckets.
uint32_t count() const
Total callbacks measured.
float avg_load() const
Average load as fraction [0.0, 1.0+].
float min_load() const
Minimum load since last reset.
float peak_load() const
Peak (worst-case) load since last reset.
uint32_t hist_bucket(size_t i) const
Read histogram bucket count (0-indexed, last bucket is >100%)
Diagnostics and profiling.
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.
int format(char *buf, size_t size, const char *fmt,...)
Format a string into a buffer (snprintf-style)