Module <cweb/speedbench.h> — simple performance samples
Collects timestamps for requests/paths for later analysis (e.g. display or optimization).
Type SpeedSample
Includes among other fields:
path— up to configurable maximum length (header: 2048).start_wall/end_wall—struct timespec.duration_ms— computed duration in milliseconds.
Functions
void cweb_init_speedbench(void)
- Purpose: Initializes internal state (history/atomics — implementation-dependent).
- Usage: Typically once at server startup (initialized together with
cweb_run_server).
void cweb_shutdown_speedbench(void)
- Purpose: Releases measurement resources.
void cweb_speedbench_start(const void *key, const char *path)
- Purpose: Starts a measurement;
keyidentifies the measurement (e.g. pointer to request/context). - Parameters:
path— descriptive path string for output.
void cweb_speedbench_end(const void *key)
- Purpose: Ends the measurement for
keyand recordsduration_ms.
const SpeedSample *cweb_get_speed_history(size_t *out_count)
- Purpose: Returns a read-only array of completed samples.
- Parameters:
out_count— number of entries. - Return: Pointer to first entry or
NULLif empty; data owned by the framework until next shutdown/reset.
Notes
- Not intended for high-frequency microbenchmarks — overhead and maximum history are implementation-dependent.
- Suitable for UI/debug, not as a sole APM tool.