|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
The header and the table. More...
The header and the table.
An entry has live fields, written by the code it measures, and window fields, a copy of the statistics for one span of time. A reader asks for a window; the measured context closes it. request_window() adds one to window_request, and the next AudioBudget::on_block_end() of a registered budget (or a call of window_point()) copies every entry's statistics into its window fields, starts the next window (the maximum, the minimum and the overruns start over; the running average and the count go on) and publishes window_seq. The reader touches the window fields only between that and its next request, so it never reads a window that is being written and the measured context is never masked.
The context that closes a window copies every entry. An entry measured in another context is copied as it stands: each field whole, the set of them possibly from before and after one of its updates.
Little-endian, every field four bytes, so the layout is the same on a 32-bit target and a 64-bit host. u32 is an unsigned integer, f32 an IEEE 754 single.
Header, at sbl_profiling_registry:
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u32 | magic | 0x464F5250, the bytes "PROF" |
| 4 | u32 | version | 1 |
| 8 | u32 | header_size | Bytes from the symbol to the first entry (40) |
| 12 | u32 | entry_size | Bytes an entry takes (64) |
| 16 | u32 | capacity | Entries the table holds |
| 20 | u32 | count | Entries registered, in registration order |
| 24 | u32 | cycle_rate | Counts per second of the cycle counter |
| 28 | u32 | window_request | Windows asked for; a reader adds one |
| 32 | u32 | window_seq | Twice the request last served; odd while a window is being written |
| 36 | u32 | reserved | 0 |
Entry i, at header_size + i * entry_size:
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u32 | kind | 1 budget, 2 section, 3 counter |
| 4 | char | name[12] | The name, NUL-terminated, 11 characters at most |
| 16 | u32 | count | Blocks, passes or events since the start |
| 20 | f32 | avg | Running average in cycles (budget, section) |
| 24 | u32 | max | Largest in the open window, in cycles |
| 28 | u32 | min | Smallest in the open window; 0xFFFFFFFF before the first |
| 32 | u32 | overruns | Budget: blocks over the limit in the open window |
| 36 | u32 | limit | Budget: cycles a block may take |
| 40 | u32 | window_count | Blocks, passes or events in the last window |
| 44 | f32 | window_avg | avg when the window closed |
| 48 | u32 | window_max | max of the window; 0 if it measured nothing |
| 52 | u32 | window_min | min of the window; 0 if it measured nothing |
| 56 | u32 | window_overruns | overruns of the window |
| 60 | u32 | window_base | count when the window closed |
A counter uses kind, name, count, window_count and window_base.
Read the header at the symbol and check magic and version; then read count entries from header_size, entry_size apart.
window_seq is even and reads the same before and after they are read. If it is odd or has changed, read again.window_request + 1 to window_request, then wait until window_seq is even and at least twice that value. The app and the tool share the windows, so a tool's request ends the app's window early. Definition at line 215 of file registry.hpp.
#include <registry.hpp>
Public Attributes | |
| uint32_t | magic |
| uint32_t | version |
| uint32_t | header_size |
| uint32_t | entry_size |
| uint32_t | capacity |
| uint32_t | count |
| uint32_t | cycle_rate |
| std::atomic< uint32_t > | window_request |
| std::atomic< uint32_t > | window_seq |
| uint32_t | reserved |
| Entry | entries [REGISTRY_CAPACITY] |
| uint32_t sbl::system::profiling::Registry::magic |
REGISTRY_MAGIC
Definition at line 216 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::version |
REGISTRY_VERSION
Definition at line 217 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::header_size |
REGISTRY_HEADER_SIZE
Definition at line 218 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::entry_size |
REGISTRY_ENTRY_SIZE
Definition at line 219 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::capacity |
REGISTRY_CAPACITY
Definition at line 220 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::count |
entries registered, in registration order
Definition at line 221 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::cycle_rate |
counts per second of the cycle counter
Definition at line 222 of file registry.hpp.
| std::atomic<uint32_t> sbl::system::profiling::Registry::window_request |
windows asked for; a reader adds one
Definition at line 223 of file registry.hpp.
| std::atomic<uint32_t> sbl::system::profiling::Registry::window_seq |
twice the request last served; odd while a window is being written
Definition at line 224 of file registry.hpp.
| uint32_t sbl::system::profiling::Registry::reserved |
0
Definition at line 225 of file registry.hpp.
| Entry sbl::system::profiling::Registry::entries[REGISTRY_CAPACITY] |
the table
Definition at line 226 of file registry.hpp.