aboutsummaryrefslogtreecommitdiff
path: root/devices/thinkpad-fan.cpp
diff options
context:
space:
mode:
authorarjan <arjan@arjan-desktop.localdomain>2010-09-18 00:03:42 -0700
committerarjan <arjan@arjan-desktop.localdomain>2010-09-18 00:03:42 -0700
commit8cda6705bc7ad0e5fc987d61b1f1a64620bdf5cd (patch)
tree3a68cb93b2351bd3244b925bce5b38dd2d99f824 /devices/thinkpad-fan.cpp
parent25f33b3443b3553b5c10ffcda05cffde4bcbf808 (diff)
downloadpowertop-8cda6705bc7ad0e5fc987d61b1f1a64620bdf5cd.tar.gz
cache the index in various places -> huge win in performance already
Diffstat (limited to 'devices/thinkpad-fan.cpp')
-rw-r--r--devices/thinkpad-fan.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/devices/thinkpad-fan.cpp b/devices/thinkpad-fan.cpp
index 286cfe0..a4fa39a 100644
--- a/devices/thinkpad-fan.cpp
+++ b/devices/thinkpad-fan.cpp
@@ -66,6 +66,13 @@ double thinkpad_fan::power_usage(struct result_bundle *result, struct parameter_
double factor;
double utilization;
+ static int fan_index = 0, fansqr_index = 0;
+
+ if (!fan_index)
+ fan_index = param_index["thinkpad-fan"];
+ if (!fansqr_index)
+ fansqr_index = param_index["thinkpad-fan-sqr"];
+
power = 0;
utilization = get_result_value("thinkpad-fan", result);
@@ -74,10 +81,10 @@ double thinkpad_fan::power_usage(struct result_bundle *result, struct parameter_
utilization = 0;
- factor = get_parameter_value("thinkpad-fan-sqr", bundle);
+ factor = get_parameter_value(fansqr_index, bundle);
power += factor * pow(utilization / 100.0, 2);
- factor = get_parameter_value("thinkpad-fan", bundle);
+ factor = get_parameter_value(fan_index, bundle);
power -= utilization * factor / 100.0;
if (power <= 0.0)