Skip to content

Commit 8a5eec0

Browse files
committed
get_cpuConsumptionWatts trys upto 5 times to update usage correctly
1 parent 532bec9 commit 8a5eec0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/linux/btop_collect.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,12 @@ namespace Cpu {
994994
auto current_timestamp = get_monotonicTimeUSec();
995995
auto current_usage = get_cpuConsumptionUJoules();
996996

997+
int i = 0;
998+
while (current_usage < previous_usage and ++i <= 4) {
999+
current_timestamp = get_monotonicTimeUSec();
1000+
current_usage = get_cpuConsumptionUJoules();
1001+
}
1002+
9971003
auto watts = (float)(current_usage - previous_usage) / (float)(current_timestamp - previous_timestamp);
9981004

9991005
previous_timestamp = current_timestamp;

0 commit comments

Comments
 (0)