1 2.. _metrics: 3 4Metrics operations 5====================== 6 7libuv provides a metrics API to track various internal operations of the event 8loop. 9 10 11Data types 12---------- 13 14.. c:type:: uv_metrics_t 15 16 The struct that contains event loop metrics. It is recommended to retrieve 17 these metrics in a :c:type:`uv_prepare_cb` in order to make sure there are 18 no inconsistencies with the metrics counters. 19 20 :: 21 22 typedef struct { 23 uint64_t loop_count; 24 uint64_t events; 25 uint64_t events_waiting; 26 /* private */ 27 uint64_t* reserved[13]; 28 } uv_metrics_t; 29 30 31Public members 32^^^^^^^^^^^^^^ 33 34.. c:member:: uint64_t uv_metrics_t.loop_count 35 36 Number of event loop iterations. 37 38.. c:member:: uint64_t uv_metrics_t.events 39 40 Number of events that have been processed by the event handler. 41 42.. c:member:: uint64_t uv_metrics_t.events_waiting 43 44 Number of events that were waiting to be processed when the event provider 45 was called. 46 47 48API 49--- 50 51.. c:function:: uint64_t uv_metrics_idle_time(uv_loop_t* loop) 52 53 Retrieve the amount of time the event loop has been idle in the kernel's 54 event provider (e.g. ``epoll_wait``). The call is thread safe. 55 56 The return value is the accumulated time spent idle in the kernel's event 57 provider starting from when the :c:type:`uv_loop_t` was configured to 58 collect the idle time. 59 60 .. note:: 61 The event loop will not begin accumulating the event provider's idle 62 time until calling :c:type:`uv_loop_configure` with 63 :c:type:`UV_METRICS_IDLE_TIME`. 64 65 .. versionadded:: 1.39.0 66 67.. c:function:: int uv_metrics_info(uv_loop_t* loop, uv_metrics_t* metrics) 68 69 Copy the current set of event loop metrics to the ``metrics`` pointer. 70 71 .. versionadded:: 1.45.0 72