aboutsummaryrefslogtreecommitdiff
path: root/devices/ahci.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/ahci.cpp
parent25f33b3443b3553b5c10ffcda05cffde4bcbf808 (diff)
downloadpowertop-8cda6705bc7ad0e5fc987d61b1f1a64620bdf5cd.tar.gz
cache the index in various places -> huge win in performance already
Diffstat (limited to 'devices/ahci.cpp')
-rw-r--r--devices/ahci.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/devices/ahci.cpp b/devices/ahci.cpp
index 3ed5455..e897cd4 100644
--- a/devices/ahci.cpp
+++ b/devices/ahci.cpp
@@ -162,8 +162,17 @@ double ahci::power_usage(struct result_bundle *result, struct parameter_bundle *
double utilization;
char buffer[4096];
+ static int active_index = 0;
+ static int partial_index = 0;
+
+ if (!active_index)
+ active_index = param_index["ahci-link-power-active"];
+
+ if (!partial_index)
+ active_index = param_index["ahci-link-power-partial"];
+
power = 0;
- factor = get_parameter_value("ahci-link-power-active", bundle);
+ factor = get_parameter_value(active_index, bundle);
sprintf(buffer, "%s-active", name);
utilization = get_result_value(buffer, result);
@@ -171,7 +180,7 @@ double ahci::power_usage(struct result_bundle *result, struct parameter_bundle *
power += utilization * factor / 100.0;
sprintf(buffer, "%s-partial", name);
- factor = get_parameter_value("ahci-link-power-partial", bundle);
+ factor = get_parameter_value(partial_index, bundle);
utilization = get_result_value(buffer, result);
power += utilization * factor / 100.0;