MagicStack / uvloop

Ultra fast asyncio event loop.
Apache License 2.0
10.45k stars 548 forks source link

feat(uvloop): Support event loop utilization queries #511

Closed caseydialpad closed 1 year ago

caseydialpad commented 2 years ago

This change seeks to expose libuv's internal uv_metrics_idle_time to permit users to tune their applications. This change is inspired by Nodejs' internalEventLoopUtilization.

The heart of this change is:


 def event_loop_utilization(self):
    """Returns idle and active time in milliseconds and the percentage of
    time the event loop is active
    """

    ...

    return idle, active, utilization
caseydialpad commented 2 years ago

Tests will be fixed by a change like https://github.com/MagicStack/uvloop/pull/512.