diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-10 20:00:17 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-10 20:00:17 +0000 |
commit | 16a78cfb366b9a12fa748593492f8fc029e12c89 (patch) | |
tree | f98c1274b239de1cc8808584d18907e952672aea /powerstats | |
parent | f51639499f12c1eba485edf02bb6dc54dbbad594 (diff) | |
parent | 9a2f0b9c3c7616b7e0c0e384355aa638a8619cc1 (diff) | |
download | pixel-android-platform-12.0.0_r28.tar.gz |
Snap for 7901677 from 9a2f0b9c3c7616b7e0c0e384355aa638a8619cc1 to sc-platform-releaseandroid-platform-12.0.0_r9android-platform-12.0.0_r8android-platform-12.0.0_r7android-platform-12.0.0_r6android-platform-12.0.0_r5android-platform-12.0.0_r4android-platform-12.0.0_r32android-platform-12.0.0_r31android-platform-12.0.0_r30android-platform-12.0.0_r3android-platform-12.0.0_r29android-platform-12.0.0_r28android-platform-12.0.0_r27android-platform-12.0.0_r26android-platform-12.0.0_r25android-platform-12.0.0_r24android-platform-12.0.0_r23android-platform-12.0.0_r22android-platform-12.0.0_r21android-platform-12.0.0_r20android-platform-12.0.0_r2android-platform-12.0.0_r19android-platform-12.0.0_r18android-platform-12.0.0_r17android-platform-12.0.0_r16android-platform-12.0.0_r15android-platform-12.0.0_r14android-platform-12.0.0_r13android-platform-12.0.0_r12android-platform-12.0.0_r11android-platform-12.0.0_r10android12-platform-release
Change-Id: I7347439ea5c87bb537e2916e9d227f2fef51a84a
Diffstat (limited to 'powerstats')
-rw-r--r-- | powerstats/dataproviders/PowerStatsEnergyConsumer.cpp | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/powerstats/dataproviders/PowerStatsEnergyConsumer.cpp b/powerstats/dataproviders/PowerStatsEnergyConsumer.cpp index c2425960..0b641659 100644 --- a/powerstats/dataproviders/PowerStatsEnergyConsumer.cpp +++ b/powerstats/dataproviders/PowerStatsEnergyConsumer.cpp @@ -119,8 +119,8 @@ bool PowerStatsEnergyConsumer::addAttribution(std::unordered_map<int32_t, std::s if (paths.count(UID_TIME_IN_STATE)) { mEnergyAttribution = PowerStatsEnergyAttribution(); AttributionStats attrStats = mEnergyAttribution.getAttributionStats(paths); - if (attrStats.uidTimeInStats.empty() || attrStats.uidTimeInStateNames.empty()) { - LOG(ERROR) << "Missing uid_time_in_state"; + if (attrStats.uidTimeInStateNames.empty()) { + LOG(ERROR) << "Failed to read uid_time_in_state"; return false; } @@ -166,44 +166,43 @@ std::optional<EnergyConsumerResult> PowerStatsEnergyConsumer::getEnergyConsumed( if (mWithAttribution) { AttributionStats attrStats = mEnergyAttribution.getAttributionStats(mAttrInfoPath); if (attrStats.uidTimeInStats.empty() || attrStats.uidTimeInStateNames.empty()) { - LOG(ERROR) << "Missing uid_time_in_state"; - return {}; - } - - int64_t totalRelativeEnergyUWs = 0; - for (const auto &uidTimeInStat : attrStats.uidTimeInStats) { - int64_t uidEnergyUWs = 0; - for (int id = 0; id < uidTimeInStat.second.size(); id++) { - if (mCoefficients.count(id)) { - int64_t d_time_in_state = uidTimeInStat.second.at(id); - if (mUidTimeInStateSS.count(uidTimeInStat.first)) { - d_time_in_state -= mUidTimeInStateSS.at(uidTimeInStat.first).at(id); + LOG(ERROR) << "Failed to read uid_time_in_state for attribution, return default EnergyConsumer"; + } else { + int64_t totalRelativeEnergyUWs = 0; + for (const auto &uidTimeInStat : attrStats.uidTimeInStats) { + int64_t uidEnergyUWs = 0; + for (int id = 0; id < uidTimeInStat.second.size(); id++) { + if (mCoefficients.count(id)) { + int64_t d_time_in_state = uidTimeInStat.second.at(id); + if (mUidTimeInStateSS.count(uidTimeInStat.first)) { + d_time_in_state -= mUidTimeInStateSS.at(uidTimeInStat.first).at(id); + } + uidEnergyUWs += mCoefficients.at(id) * d_time_in_state; } - uidEnergyUWs += mCoefficients.at(id) * d_time_in_state; } + totalRelativeEnergyUWs += uidEnergyUWs; + + EnergyConsumerAttribution attr = { + .uid = uidTimeInStat.first, + .energyUWs = uidEnergyUWs, + }; + attribution.emplace_back(attr); } - totalRelativeEnergyUWs += uidEnergyUWs; - EnergyConsumerAttribution attr = { - .uid = uidTimeInStat.first, - .energyUWs = uidEnergyUWs, - }; - attribution.emplace_back(attr); - } + int64_t d_totalEnergyUWs = totalEnergyUWs - mTotalEnergySS; + float powerScale = 0; + if (totalRelativeEnergyUWs != 0) { + powerScale = static_cast<float>(d_totalEnergyUWs) / totalRelativeEnergyUWs; + } + for (auto &attr : attribution) { + attr.energyUWs = (int64_t)(attr.energyUWs * powerScale) + + (mUidEnergySS.count(attr.uid) ? mUidEnergySS.at(attr.uid) : 0); + mUidEnergySS[attr.uid] = attr.energyUWs; + } - int64_t d_totalEnergyUWs = totalEnergyUWs - mTotalEnergySS; - float powerScale = 0; - if (totalRelativeEnergyUWs != 0) { - powerScale = static_cast<float>(d_totalEnergyUWs) / totalRelativeEnergyUWs; + mUidTimeInStateSS = attrStats.uidTimeInStats; + mTotalEnergySS = totalEnergyUWs; } - for (auto &attr : attribution) { - attr.energyUWs = (int64_t)(attr.energyUWs * powerScale) + - (mUidEnergySS.count(attr.uid) ? mUidEnergySS.at(attr.uid) : 0); - mUidEnergySS[attr.uid] = attr.energyUWs; - } - - mUidTimeInStateSS = attrStats.uidTimeInStats; - mTotalEnergySS = totalEnergyUWs; } else { std::vector<StateResidencyResult> results; if (mPowerStats->getStateResidency({mPowerEntityId}, &results).isOk()) { |