Reading min, max values for ‘cap’ every 8 times.
There is no need to read min and max values of CPU
capabilities with every second. The CPU capabilities
doesn’t change to often if ever. The hwmon updated the
cap files with cycle of 10sec.
Reading min and max value every 8 times should be enough
in this case.
Tested:
Working as expected, no regression detected.
Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: I86c6b5542d3e2f3475aef3c5b05b305f87c6ef39
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 127d68a..d68e980 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -47,7 +47,8 @@
minReading, PowerState::on),
objServer(objectServer), inputDev(io), waitTimer(io), path(path),
privTcontrol(std::numeric_limits<double>::quiet_NaN()),
- dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs)
+ dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs),
+ minMaxReadCounter(0)
{
nameTcontrol = labelTcontrol;
nameTcontrol += " CPU" + std::to_string(cpuId);
@@ -235,7 +236,10 @@
{
value = nvalue;
}
- updateMinMaxValues();
+ if (minMaxReadCounter++ % 8 == 0)
+ {
+ updateMinMaxValues();
+ }
double gTcontrol = gCpuSensors[nameTcontrol]
? gCpuSensors[nameTcontrol]->value