[php-src] Issue #11080: Add `cpu_get_usage` function

From: Date: Sat, 15 Apr 2023 13:41:14 +0000
Subject: [php-src] Issue #11080: Add `cpu_get_usage` function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244202@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11080 Author: mvorisek ### Description Currently there is no easy and fast way to measure spent instruction directly from PHP. Linux tracks spent CPU instructions per process since ages, Windows can track that since Windows 7 thru QueryThreadCycleTime [1]. This is a feature request to to add cpu_get_usage(): int function to PHP which will return a number of CPU instructions spent (in user+kernel mode) for the current php process since the process start. This will allow to measure performance sensitive methods directly from PHP even on busy machines (like GitHub CI) where time measurements are very unaccurate due system load, different CPU frequencies and schedulling pauses. [1] https://learn.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-querythreadcycletime

« previous php.bugs (#244202) next »