diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2018-05-08 15:47:12 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@linux.ibm.com> | 2018-05-17 16:13:41 +0000 |
commit | e0f67c8b81d9b19d277e53c1c1a5c169ef54ed82 (patch) | |
tree | 9e7576a86222e855aebe0321f238b55034358a04 /control | |
parent | 572d406c89c80da2bb7ec4ccb42d2de3236000e1 (diff) | |
download | phosphor-fan-presence-e0f67c8b81d9b19d277e53c1c1a5c169ef54ed82.tar.gz phosphor-fan-presence-e0f67c8b81d9b19d277e53c1c1a5c169ef54ed82.zip |
perf: Count state of properties before set speed
Once the number of properties at a given state are at/above the given
number allowed, set the fan speed and stop checking the remaining
properties.
Tested:
Action function results are unchanged
Change-Id: Icfd347703c973b12f4b7806ea1ba84056f987253
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rw-r--r-- | control/actions.hpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/control/actions.hpp b/control/actions.hpp index c7356ab..b079bf4 100644 --- a/control/actions.hpp +++ b/control/actions.hpp @@ -88,27 +88,28 @@ auto count_state_before_speed(size_t count, T&& state, uint64_t speed) speed, state = std::forward<T>(state)](auto& zone, auto& group) { - size_t numAtState = std::count_if( - group.begin(), - group.end(), - [&zone, &state](auto const& entry) + size_t numAtState = 0; + for (auto& entry : group) + { + try { - try - { - return zone.template getPropertyValue<T>( - entry.first, - std::get<intfPos>(entry.second), - std::get<propPos>(entry.second)) == state; - } - catch (const std::out_of_range& oore) + if (zone.template getPropertyValue<T>( + entry.first, + std::get<intfPos>(entry.second), + std::get<propPos>(entry.second)) == state) { - // Default to property not equal when not found - return false; + numAtState++; } - }); - if (numAtState >= count) - { - zone.setSpeed(speed); + } + catch (const std::out_of_range& oore) + { + // Default to property not equal when not found + } + if (numAtState >= count) + { + zone.setSpeed(speed); + break; + } } // Update group's fan control active allowed based on action results zone.setActiveAllow(&group, !(numAtState >= count)); |