32#ifndef SBL_SYSTEM_PROFILING_SECTION_HPP_
33#define SBL_SYSTEM_PROFILING_SECTION_HPP_
41#ifdef SBL_PROFILING_ENABLED
46 [[nodiscard]]
bool register_as(
const char* name) {
return slot_.enroll(Kind::Section, name); }
49 void update(uint32_t
cycles) { slot_.stats().measure(
cycles); }
52 uint32_t avg()
const {
return static_cast<uint32_t
>(std::lround(slot_.stats().avg)); }
55 uint32_t max()
const {
return slot_.stats().max; }
58 uint32_t min()
const {
return slot_.stats().min ==
NO_MINIMUM ? 0 : slot_.stats().min; }
61 uint32_t count()
const {
return slot_.stats().count; }
64 void reset_window() { slot_.stats().open_window(); }
67 void reset() { slot_.stats().clear(); }
77 [[nodiscard]]
static bool register_as(
const char*) {
return true; }
78 static void update(uint32_t) {}
79 static uint32_t avg() {
return 0; }
80 static uint32_t max() {
return 0; }
81 static uint32_t min() {
return 0; }
82 static uint32_t count() {
return 0; }
83 static void reset_window() {}
84 static void reset() {}
92#ifdef SBL_PROFILING_ENABLED
93#define SBL_PROF_MARK(var) uint32_t var = sbl::system::profiling::cycles()
95#define SBL_PROF_MARK(var) (void)0
99#ifdef SBL_PROFILING_ENABLED
100#define SBL_PROF_SECTION(section, start) \
102 uint32_t _end = sbl::system::profiling::cycles(); \
103 (section).update(_end - (start)); \
107#define SBL_PROF_SECTION(section, start) (void)0
Profiling: the cycle counter, the audio budget, section profiles and reports.
constexpr uint32_t NO_MINIMUM
The profiling registry: every budget, section and counter in one table.