mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-16 08:40:06 +02:00
42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
From d0ea409005cecef76c6fcb7a0cefd0a662d340e0 Mon Sep 17 00:00:00 2001
|
|
From: Chirayu Desai <chirayudesai1@gmail.com>
|
|
Date: Wed, 3 Dec 2014 19:50:33 +0000
|
|
Subject: [PATCH] CPUPercent: Update for new API
|
|
|
|
---
|
|
CPUPercent.cpp | 9 +++++++--
|
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/CPUPercent.cpp b/CPUPercent.cpp
|
|
index 3e4c8e8931..4225f73642 100644
|
|
--- a/CPUPercent.cpp
|
|
+++ b/CPUPercent.cpp
|
|
@@ -19,17 +19,22 @@ void CPU_Percent::Update()
|
|
{
|
|
system_info info;
|
|
get_system_info(&info);
|
|
+
|
|
+ cpu_info* cpuInfos = new cpu_info[info.cpu_count];
|
|
+ get_cpu_info(0, info.cpu_count, cpuInfos);
|
|
|
|
delta_system = (double)system_time() - last_system_time;
|
|
- delta_cpu = double(info.cpu_infos[theCPU].active_time) - last_active_cpu_time;
|
|
+ delta_cpu = double(cpuInfos[theCPU].active_time) - last_active_cpu_time;
|
|
|
|
percent = (delta_cpu/delta_system);
|
|
if(percent < 0) percent = 0.00;
|
|
if(percent > 1) percent = 1.00;
|
|
|
|
lastpercent = percent;
|
|
- last_active_cpu_time = (double)info.cpu_infos[theCPU].active_time;
|
|
+ last_active_cpu_time = (double)cpuInfos[theCPU].active_time;
|
|
last_system_time = (double)system_time();
|
|
+
|
|
+ delete[] cpuInfos;
|
|
}
|
|
|
|
double CPU_Percent::Percentage()
|
|
--
|
|
1.8.3.4
|
|
|