1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef XPOWER_STDTYPE_H 17 #define XPOWER_STDTYPE_H 18 #include "base_stdtype.h" 19 20 namespace SysTuning { 21 namespace TraceStdtype { 22 class XPowerAppStatistic : public CacheBase, public BatchCacheBase { 23 public: 24 size_t AppendNewAppStatisticData(DataIndex componentType, uint64_t startTime, uint64_t dur, int64_t energy); 25 const std::deque<DataIndex> &ComponentTypesData() const; 26 const std::deque<int64_t> &DurationsData() const; 27 const std::deque<int64_t> &EnergysData() const; 28 void Clear() override; 29 void ClearExportedData() override; 30 31 private: 32 std::deque<DataIndex> componentTypes_ = {}; 33 std::deque<int64_t> durs_ = {}; 34 std::deque<int64_t> energys_ = {}; 35 }; 36 37 class XPowerAppDetailCPU : public CacheBase, public BatchCacheBase { 38 public: 39 size_t AppendNewAppDetailCPUData(DataIndex threadName, 40 uint64_t startTime, 41 uint64_t threadTime, 42 int64_t threadLoad, 43 int64_t threadEnergy); 44 const std::deque<DataIndex> &ThreadNamesData() const; 45 const std::deque<int64_t> &ThreadTimesData() const; 46 const std::deque<int64_t> &ThreadLoadsData() const; 47 const std::deque<int64_t> &ThreadEnergysData() const; 48 void Clear() override; 49 void ClearExportedData() override; 50 51 private: 52 std::deque<DataIndex> threadNames_ = {}; 53 std::deque<int64_t> threadTimes_ = {}; 54 std::deque<int64_t> threadLoads_ = {}; 55 std::deque<int64_t> threadEnergys_ = {}; 56 }; 57 58 class XPowerAppDetailGPU : public CacheBase, public BatchCacheBase { 59 public: 60 size_t AppendNewAppDetailGPUData(int64_t frequency, uint64_t startTime, int64_t idleTime, int64_t runTime); 61 const std::deque<int64_t> &FrequencysData() const; 62 const std::deque<int64_t> &IdleTimesData() const; 63 const std::deque<int64_t> &RuntimesData() const; 64 void Clear() override; 65 void ClearExportedData() override; 66 67 private: 68 std::deque<int64_t> frequencys_ = {}; 69 std::deque<int64_t> idleTimes_ = {}; 70 std::deque<int64_t> runTimes_ = {}; 71 }; 72 73 class XPowerAppDetailWifi : public CacheBase, public BatchCacheBase { 74 public: 75 size_t AppendNewAppDetailWifiData(uint64_t startTime, 76 int64_t txPackets, 77 int64_t rxPackets, 78 int64_t txBytes, 79 int64_t rxBytes); 80 const std::deque<int64_t> &TxPacketsData() const; 81 const std::deque<int64_t> &RxPacketsData() const; 82 const std::deque<int64_t> &TxBytesData() const; 83 const std::deque<int64_t> &RxBytesData() const; 84 void Clear() override; 85 void ClearExportedData() override; 86 87 private: 88 std::deque<int64_t> txPackets_ = {}; 89 std::deque<int64_t> rxPackets_ = {}; 90 std::deque<int64_t> txBytes_ = {}; 91 std::deque<int64_t> rxBytes_ = {}; 92 }; 93 94 struct XPowerAppDetailDisplayRow { 95 uint64_t startTime = INVALID_UINT64; 96 int64_t count1Hertz = INVALID_INT64; 97 int64_t count5Hertz = INVALID_INT64; 98 int64_t count10Hertz = INVALID_INT64; 99 int64_t count15Hertz = INVALID_INT64; 100 int64_t count24Hertz = INVALID_INT64; 101 int64_t count30Hertz = INVALID_INT64; 102 int64_t count45Hertz = INVALID_INT64; 103 int64_t count60Hertz = INVALID_INT64; 104 int64_t count90Hertz = INVALID_INT64; 105 int64_t count120Hertz = INVALID_INT64; 106 int64_t count180Hertz = INVALID_INT64; 107 }; 108 109 class XPowerAppDetailDisplay : public CacheBase, public BatchCacheBase { 110 public: 111 size_t AppendNewAppDetailDisplayData(const XPowerAppDetailDisplayRow &row); 112 const std::deque<int64_t> &Count1HertzsData() const; 113 const std::deque<int64_t> &Count5HertzsData() const; 114 const std::deque<int64_t> &Count10HertzsData() const; 115 const std::deque<int64_t> &Count15HertzsData() const; 116 const std::deque<int64_t> &Count24HertzsData() const; 117 const std::deque<int64_t> &Count30HertzsData() const; 118 const std::deque<int64_t> &Count45HertzsData() const; 119 const std::deque<int64_t> &Count60HertzsData() const; 120 const std::deque<int64_t> &Count90HertzsData() const; 121 const std::deque<int64_t> &Count120HertzsData() const; 122 const std::deque<int64_t> &Count180HertzsData() const; 123 void Clear() override; 124 void ClearExportedData() override; 125 126 private: 127 std::deque<int64_t> count1Hertzs_ = {}; 128 std::deque<int64_t> count5Hertzs_ = {}; 129 std::deque<int64_t> count10Hertzs_ = {}; 130 std::deque<int64_t> count15Hertzs_ = {}; 131 std::deque<int64_t> count24Hertzs_ = {}; 132 std::deque<int64_t> count30Hertzs_ = {}; 133 std::deque<int64_t> count45Hertzs_ = {}; 134 std::deque<int64_t> count60Hertzs_ = {}; 135 std::deque<int64_t> count90Hertzs_ = {}; 136 std::deque<int64_t> count120Hertzs_ = {}; 137 std::deque<int64_t> count180Hertzs_ = {}; 138 }; 139 140 struct XPowerComponentTopRow { 141 DataIndex componentType = INVALID_UINT64; 142 uint64_t startTime = INVALID_UINT64; 143 int64_t appname = INVALID_INT64; 144 int64_t backgroundDuration = INVALID_INT64; 145 int64_t backgroundEnergy = INVALID_INT64; 146 int64_t foregroundDuration = INVALID_INT64; 147 int64_t foregroundEnergy = INVALID_INT64; 148 int64_t screenOffDuration = INVALID_INT64; 149 int64_t screenOffEnergy = INVALID_INT64; 150 int64_t screenOnDuration = INVALID_INT64; 151 int64_t screenOnEnergy = INVALID_INT64; 152 int64_t cameraId = INVALID_INT64; 153 int64_t uid = INVALID_INT64; 154 int64_t load = INVALID_INT64; 155 int64_t appUsageDuration = INVALID_INT64; 156 int64_t appUsageEnergy = INVALID_INT64; 157 }; 158 159 class XPowerComponentTop : public CacheBase, public BatchCacheBase { 160 public: 161 size_t AppendNewComponentTopData(const XPowerComponentTopRow &row); 162 const std::deque<DataIndex> &ComponentTypesData() const; 163 const std::deque<int64_t> &AppnamesData() const; 164 const std::deque<int64_t> &BackgroundDurationsData() const; 165 const std::deque<int64_t> &BackgroundEnergysData() const; 166 const std::deque<int64_t> &ForegroundDurationsData() const; 167 const std::deque<int64_t> &ForegroundEnergysData() const; 168 const std::deque<int64_t> &ScreenOffDurationsData() const; 169 const std::deque<int64_t> &ScreenOffEnergysData() const; 170 const std::deque<int64_t> &ScreenOnDurationsData() const; 171 const std::deque<int64_t> &ScreenOnEnergysData() const; 172 const std::deque<int64_t> &CameraIdsData() const; 173 const std::deque<int64_t> &UidsData() const; 174 const std::deque<int64_t> &LoadsData() const; 175 const std::deque<int64_t> &AppUsageDurationsData() const; 176 const std::deque<int64_t> &AppUsageEnergysData() const; 177 void Clear() override; 178 void ClearExportedData() override; 179 180 private: 181 std::deque<DataIndex> componentTypes_ = {}; 182 std::deque<int64_t> appnames_ = {}; 183 std::deque<int64_t> backgroundDurations_ = {}; 184 std::deque<int64_t> backgroundEnergys_ = {}; 185 std::deque<int64_t> foregroundDurations_ = {}; 186 std::deque<int64_t> foregroundEnergys_ = {}; 187 std::deque<int64_t> screenOffDurations_ = {}; 188 std::deque<int64_t> screenOffEnergys_ = {}; 189 std::deque<int64_t> screenOnDurations_ = {}; 190 std::deque<int64_t> screenOnEnergys_ = {}; 191 std::deque<int64_t> cameraIds_ = {}; 192 std::deque<int64_t> uids_ = {}; 193 std::deque<int64_t> loads_ = {}; 194 std::deque<int64_t> appUsageDurations_ = {}; 195 std::deque<int64_t> appUsageEnergys_ = {}; 196 }; 197 198 } // namespace TraceStdtype 199 } // namespace SysTuning 200 #endif // XPOWER_STDTYPE_H