tiny_bench.h Overview¶
tiny_bench.h is the unified entry header for TinyBench, aggregating:
tiny_bench_config.h— compile-time configuration- Type system enum
tiny_type_t - Tool function signature
tiny_tool_fn - Data slot and tool API declarations
Type System tiny_type_t¶
Every data slot and tool carries a type tag for runtime type safety:
typedef enum {
TINY_TYPE_UNKNOWN = 0,
TINY_TYPE_F32, // float scalar
TINY_TYPE_F32_ARR, // float[] array
TINY_TYPE_CF32, // _Complex float
TINY_TYPE_CF32_ARR, // _Complex float[]
TINY_TYPE_SYSID_RESULT, // tiny_sysid_result_t
TINY_TYPE_DAMAGE_DETECT, // tiny_damage_detect_t
TINY_TYPE_DAMAGE_LOCATE, // tiny_damage_locate_t
TINY_TYPE_DAMAGE_ASSESS, // tiny_damage_assess_t
TINY_TYPE_U8_ARR, // uint8_t[] raw bytes
} tiny_type_t;
Type names can be converted to readable strings (e.g., "f32[]", "sysid_result") via tiny_bench_type_name(type).
Tool Function Signature tiny_tool_fn¶
All Tiny* processing functions are uniformly wrapped as this signature:
The caller is responsible for passing correctly typed pointers. Type validation is performed by Orch at registration and flow definition time.
Core Data Structures¶
Data Slot tiny_bench_slot_t¶
typedef struct {
char name[TINY_BENCH_NAME_LEN]; // canonical name
void *data; // pointer to data
size_t len; // byte length
tiny_type_t type; // type tag
bool used; // slot in use
} tiny_bench_slot_t;
Tool Entry tiny_bench_tool_t¶
typedef struct {
char name[TINY_BENCH_NAME_LEN]; // canonical name
tiny_tool_fn fn; // function pointer
tiny_type_t in_type; // expected input type
tiny_type_t out_type; // output type
bool used; // slot in use
} tiny_bench_tool_t;
Bench tiny_bench_t¶
typedef struct {
tiny_bench_slot_t slots[TINY_BENCH_MAX_DATA]; // data slot table
tiny_bench_tool_t tools[TINY_BENCH_MAX_TOOLS]; // tool table
} tiny_bench_t;
All tables are statically allocated at tiny_bench_init() time, with zero heap allocation at runtime.
API Overview¶
Initialization¶
| Function | Purpose |
|---|---|
tiny_bench_init(bench) | Zero-initialize all slots and tool tables |
Data Slot Management¶
| Function | Purpose | Error Code |
|---|---|---|
tiny_bench_put(bench, name, data, len, type) | Put named data onto the bench | OK, FULL, EXISTS |
tiny_bench_get(bench, name, &data, &len, &type) | Get named data | OK, NOT_FOUND |
tiny_bench_remove(bench, name) | Remove data slot (does not free data) | OK, NOT_FOUND |
tiny_bench_list_data(bench, names, max) | List all data slot names | Returns count |
tiny_bench_clear(bench) | Clear all data slots | — |
Tool Registration Management¶
| Function | Purpose | Error Code |
|---|---|---|
tiny_bench_register_tool(bench, name, fn, in, out) | Register a tool | OK, FULL, EXISTS |
tiny_bench_tool_info(bench, name, &in, &out) | Query tool types | OK, NOT_FOUND |
tiny_bench_get_tool_fn(bench, name, &fn, &in, &out) | Get tool function pointer + types | OK, NOT_FOUND |
tiny_bench_list_tools(bench, names, max) | List all tool names | Returns count |
Utility Functions¶
| Function | Purpose |
|---|---|
tiny_bench_type_name(type) | Convert type enum to readable string |
Error Codes¶
typedef enum {
TINY_BENCH_OK = 0,
TINY_BENCH_ERR_NULL = -1, // NULL pointer argument
TINY_BENCH_ERR_NOT_FOUND = -2, // name does not exist
TINY_BENCH_ERR_FULL = -3, // table is full
TINY_BENCH_ERR_EXISTS = -4, // name already exists
TINY_BENCH_ERR_NAME_LEN = -5, // name exceeds max length
TINY_BENCH_ERR_TYPE = -6, // type mismatch
} tiny_bench_err_t;
tiny_bench_config.h Configuration¶
| Macro | Default | Description |
|---|---|---|
TINY_BENCH_MAX_DATA | 16 | Maximum number of named data slots |
TINY_BENCH_MAX_TOOLS | 32 | Maximum number of registered tools |
TINY_BENCH_NAME_LEN | 24 | Maximum name length (including '\0') |
Can be overridden at compile time with -D.