ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
callback_timing.h
Go to the documentation of this file.
1
12
13#ifndef WEBSOCKET_CALLBACK_TIMING_H
14#define WEBSOCKET_CALLBACK_TIMING_H
15
16#include <stdint.h>
17#include <libplatform/atomic.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
31typedef struct {
32 atomic_t count; // Total invocations
33 atomic_t last_ns; // Last callback timestamp (nanoseconds)
34 atomic_t min_interval_ns; // Minimum interval between callbacks
35 atomic_t max_interval_ns; // Maximum interval between callbacks
36 atomic_t total_duration_ns; // Cumulative callback duration
38
50
57
65static inline uint64_t websocket_callback_timing_start(void) {
66 return time_get_ns();
67}
68
79
87
94
95#endif // WEBSOCKET_CALLBACK_TIMING_H
96
97#ifdef __cplusplus
98}
99#endif
websocket_callback_timing_t g_ws_callback_timing
Global timing tracker - shared across all WebSocket connections.
void websocket_callback_timing_reset(void)
Reset timing statistics.
void websocket_callback_timing_record(websocket_callback_stats_t *stats, uint64_t start_ns, uint64_t end_ns)
Record callback invocation.
void websocket_callback_timing_log_stats(void)
Log current callback statistics.
unsigned long long uint64_t
Atomic value wrapper for integral/boolean types.
Definition atomic.h:80
Counters and timing aggregates for one WebSocket callback kind.
Timing aggregates for protocol-init, teardown, writable, and receive callbacks.
websocket_callback_stats_t receive
websocket_callback_stats_t protocol_destroy
websocket_callback_stats_t server_writeable
websocket_callback_stats_t protocol_init
⏱️ High-precision timing utilities using sokol_time.h and uthash