From f0904133929e343c23988a16d6e616bc4e0c5c76 Mon Sep 17 00:00:00 2001 From: "a.chubar" Date: Mon, 23 Sep 2024 18:04:47 +0300 Subject: [PATCH] Added CPU freq measurements --- device.inc.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/device.inc.php b/device.inc.php index 41b07d4..da08cd5 100644 --- a/device.inc.php +++ b/device.inc.php @@ -278,6 +278,42 @@ function device_cputop_async(string $atf_host, string $device) : Amp\Promise }); } +function device_cpu_freq_min_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise +{ + return device_cpu_measure_async($atf_host, $device, "cpuinfo_min_freq", $core_index); +} + +function device_cpu_freq_max_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise +{ + return device_cpu_measure_async($atf_host, $device, "cpuinfo_max_freq", $core_index); +} + +function device_cpu_freq_cur_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise +{ + return device_cpu_measure_async($atf_host, $device, "scaling_cur_freq", $core_index); +} + +function device_cpu_measure_async(string $atf_host, string $device, string $metric, int $core_index) : Amp\Promise +{ + return Amp\call(function() use($atf_host, $device, $metric, $core_index) { + //NOTE: on current devices 16 thermal zone are responsible for GPU temperature probing + list($code, $lines) = yield host_exec_async($atf_host, "%{adb}% -s $device shell cat /sys/devices/system/cpu/cpu$core_index/cpufreq/$metric", DEPLOY_OPT_ERR_OK, 1); + + if($code !== 0) + return 0; + + foreach($lines as $idx => $line) + { + $line = trim($line); + if(!$line) + continue; + return intval($line); + } + + return 0; + }); +} + function device_temperature_async(string $atf_host, string $device) : Amp\Promise { return Amp\call(function() use($atf_host, $device) {