• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. 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 #include <cstdint>
16 #include <string>
17 
18 #include "pbreader_xpower_parser.h"
19 #include "clock_filter_ex.h"
20 #include "measure_filter.h"
21 #include "proto_reader_help.h"
22 #include "ts_common.h"
23 #include "xpower_plugin_result.pbreader.h"
24 #include "xpower_plugin_result.pb.h"
25 
26 namespace SysTuning {
27 namespace TraceStreamer {
PbreaderXpowerParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)28 PbreaderXpowerParser::PbreaderXpowerParser(TraceDataCache *dataCache, const TraceStreamerFilters *ctx)
29     : EventParserBase(dataCache, ctx)
30 {
31 }
32 
~PbreaderXpowerParser()33 PbreaderXpowerParser::~PbreaderXpowerParser()
34 {
35     TS_LOGI("mem ts MIN:%llu, MAX:%llu", static_cast<unsigned long long>(GetPluginStartTime()),
36             static_cast<unsigned long long>(GetPluginEndTime()));
37 }
Parse(PbreaderDataSegment & seg,uint64_t timestamp,BuiltinClocks clock)38 void PbreaderXpowerParser::Parse(PbreaderDataSegment &seg, uint64_t timestamp, BuiltinClocks clock)
39 {
40     ProtoReader::OptimizeReport_Reader optimizeReport(seg.protoData.data_, seg.protoData.size_);
41     if (!optimizeReport.has_start_time() || !optimizeReport.has_end_time()) {
42         return;
43     }
44     auto startTime =
45         streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, optimizeReport.start_time() * MSEC_TO_NS);
46     auto endTime =
47         streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, optimizeReport.end_time() * MSEC_TO_NS);
48     if (timeSet_.find(startTime) != timeSet_.end()) {
49         return;
50     }
51     UpdatePluginTimeRange(TS_CLOCK_REALTIME, optimizeReport.start_time() * MSEC_TO_NS, startTime);
52     UpdatePluginTimeRange(TS_CLOCK_REALTIME, optimizeReport.end_time() * MSEC_TO_NS, endTime);
53     traceDataCache_->UpdateTraceTime(startTime);
54     traceDataCache_->UpdateTraceTime(endTime);
55     timeSet_.emplace(startTime);
56     static bool initBundleName = false;
57     if (!initBundleName && optimizeReport.has_bundle_name()) {
58         traceDataCache_->GetTraceConfigData()->AppendNewData("xpower_config", "bundle_name",
59                                                              optimizeReport.bundle_name().ToStdString());
60         initBundleName = true;
61     }
62     if (optimizeReport.has_real_battery()) {
63         ProcessRealBattery(optimizeReport.real_battery(), startTime);
64     }
65     if (optimizeReport.has_thermal_report()) {
66         ProcessThermalReport(optimizeReport.thermal_report(), startTime);
67     }
68     if (optimizeReport.has_app_statistic()) {
69         ProcessAppStatistic(optimizeReport.app_statistic(), startTime);
70     }
71     if (optimizeReport.has_app_detail()) {
72         ProcessAppDetail(optimizeReport.app_detail(), startTime);
73     }
74     if (optimizeReport.has_component_top()) {
75         ProcessComponentTop(optimizeReport.component_top(), startTime);
76     }
77 }
78 
ProcessRealBattery(const ProtoReader::BytesView & bytesView,uint64_t timestamp)79 void PbreaderXpowerParser::ProcessRealBattery(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
80 {
81     ProtoReader::RealBattery_Reader realBattery(bytesView);
82     auto capacity = realBattery.capacity();
83     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaCapDataIndex_, timestamp,
84                                                          capacity);
85     auto charge = realBattery.charge();
86     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaChaDataIndex_, timestamp,
87                                                          charge);
88     auto gasGauge = realBattery.gas_gauge();
89     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaGasDataIndex_, timestamp,
90                                                          gasGauge);
91     auto level = realBattery.level();
92     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaLevDataIndex_, timestamp,
93                                                          level);
94     auto screen = realBattery.screen();
95     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaScrDataIndex_, timestamp,
96                                                          screen);
97     bool errorInfo = false;
98     auto realCurrent = realBattery.real_current(&errorInfo);
99     uint64_t count = 0;
100     while (realCurrent) {
101         streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, rBaRealCurDataIndex_,
102                                                              timestamp + 100 * MSEC_TO_NS * count, *realCurrent);
103         realCurrent++;
104         count++;
105     }
106 }
107 
ProcessThermalReport(const ProtoReader::BytesView & bytesView,uint64_t timestamp)108 void PbreaderXpowerParser::ProcessThermalReport(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
109 {
110     ProtoReader::ThermalReport_Reader thermalReport(bytesView);
111     auto shellTemp = thermalReport.shell_temp();
112     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, tReSheDataIndex_, timestamp,
113                                                          shellTemp);
114     auto thermalLevel = thermalReport.thermal_level();
115     streamFilters_->measureFilter_->AppendNewMeasureData(EnumMeasureFilter::XPOWER, 0, tReTheDataIndex_, timestamp,
116                                                          thermalLevel);
117 }
118 
ProcessAppStatistic(const ProtoReader::BytesView & bytesView,uint64_t timestamp)119 void PbreaderXpowerParser::ProcessAppStatistic(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
120 {
121     ProtoReader::AppStatistic_Reader appStatistic(bytesView);
122     if (appStatistic.has_audio()) {
123         ProcessAppStatisticCommon(appStatistic.audio(), timestamp, audioStr_);
124     }
125     if (appStatistic.has_bluetooth()) {
126         ProcessAppStatisticCommon(appStatistic.bluetooth(), timestamp, bluetoothStr_);
127     }
128     if (appStatistic.has_camera()) {
129         ProcessAppStatisticCommon(appStatistic.camera(), timestamp, cameraStr_);
130     }
131     if (appStatistic.has_cpu()) {
132         ProcessAppStatisticCommon(appStatistic.cpu(), timestamp, cpuStr_);
133     }
134     if (appStatistic.has_display()) {
135         ProcessAppStatisticCommon(appStatistic.audio(), timestamp, displayStr_);
136     }
137     if (appStatistic.has_flashlight()) {
138         ProcessAppStatisticCommon(appStatistic.flashlight(), timestamp, flashlightStr_);
139     }
140     if (appStatistic.has_gpu()) {
141         ProcessAppStatisticCommon(appStatistic.gpu(), timestamp, gpuStr_);
142     }
143     if (appStatistic.has_location()) {
144         ProcessAppStatisticCommon(appStatistic.location(), timestamp, locationStr_);
145     }
146     if (appStatistic.has_wifiscan()) {
147         ProcessAppStatisticCommon(appStatistic.wifiscan(), timestamp, wifiscanStr_);
148     }
149     if (appStatistic.has_wifi()) {
150         ProcessAppStatisticCommon(appStatistic.wifi(), timestamp, wifiStr_);
151     }
152     if (appStatistic.has_modem()) {
153         ProcessAppStatisticCommon(appStatistic.modem(), timestamp, modemStr_);
154     }
155 }
156 
ProcessAppStatisticCommon(const ProtoReader::BytesView & bytesView,uint64_t timestamp,const std::string & name)157 void PbreaderXpowerParser::ProcessAppStatisticCommon(const ProtoReader::BytesView &bytesView,
158                                                      uint64_t timestamp,
159                                                      const std::string &name)
160 {
161     ProtoReader::AppStatisticCommon_Reader appStatisticCommon(bytesView);
162     int64_t duration = INVALID_INT64;
163     int64_t energy = INVALID_INT64;
164     if (appStatisticCommon.has_energy()) {
165         energy = appStatisticCommon.energy();
166     }
167     if (appStatisticCommon.has_time()) {
168         duration = appStatisticCommon.time();
169     }
170     if (appStatisticCommon.has_energy() || appStatisticCommon.has_time()) {
171         traceDataCache_->GetXPowerAppStatisticInfo()->AppendNewAppStatisticData(traceDataCache_->GetDataIndex(name),
172                                                                                 timestamp, duration, energy);
173     }
174 }
175 
ProcessAppDetail(const ProtoReader::BytesView & bytesView,uint64_t timestamp)176 void PbreaderXpowerParser::ProcessAppDetail(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
177 {
178     ProtoReader::AppDetail_Reader appDetail(bytesView);
179     if (appDetail.has_cpu()) {
180         ProcessAppDetailCpu(appDetail.cpu(), timestamp);
181     }
182     if (appDetail.has_gpu()) {
183         ProcessAppDetailGpu(appDetail.gpu(), timestamp);
184     }
185     if (appDetail.has_wifi()) {
186         ProcessAppDetailWifi(appDetail.wifi(), timestamp);
187     }
188     if (appDetail.has_display()) {
189         ProcessAppDetailDisplay(appDetail.display(), timestamp);
190     }
191 }
ProcessAppDetailCpu(const ProtoReader::BytesView & bytesView,uint64_t timestamp)192 void PbreaderXpowerParser::ProcessAppDetailCpu(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
193 {
194     ProtoReader::AppDetailCPU_Reader appDetailCPU(bytesView);
195     bool errorInfo = false;
196     auto threadName = appDetailCPU.thread_name();
197     auto threadLoad = appDetailCPU.thread_load(&errorInfo);
198     auto threadTime = appDetailCPU.thread_time(&errorInfo);
199     auto threadEnergy = appDetailCPU.thread_energy(&errorInfo);
200     while (threadName && threadLoad && threadTime && threadEnergy) {
201         auto naneIndex = traceDataCache_->GetDataIndex(threadName->ToStdString());
202         traceDataCache_->GetXPowerAppDetailCPUInfo()->AppendNewAppDetailCPUData(naneIndex, timestamp, *threadTime,
203                                                                                 *threadLoad, *threadEnergy);
204         threadName++;
205         threadLoad++;
206         threadTime++;
207         threadEnergy++;
208     }
209 }
ProcessAppDetailGpu(const ProtoReader::BytesView & bytesView,uint64_t timestamp)210 void PbreaderXpowerParser::ProcessAppDetailGpu(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
211 {
212     ProtoReader::AppDetailGPU_Reader appDetailGPU(bytesView);
213     bool errorInfo = false;
214     auto frequency = appDetailGPU.frequency(&errorInfo);
215     auto idleTime = appDetailGPU.idle_time(&errorInfo);
216     auto runTime = appDetailGPU.run_time(&errorInfo);
217     while (frequency && idleTime && runTime) {
218         traceDataCache_->GetXPowerAppDetailGPUInfo()->AppendNewAppDetailGPUData(*frequency, timestamp, *idleTime,
219                                                                                 *runTime);
220         frequency++;
221         idleTime++;
222         runTime++;
223     }
224 }
ProcessAppDetailWifi(const ProtoReader::BytesView & bytesView,uint64_t timestamp)225 void PbreaderXpowerParser::ProcessAppDetailWifi(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
226 {
227     ProtoReader::AppDetailWifi_Reader appDetailWifi(bytesView);
228     int64_t txPackets = INVALID_INT64;
229     int64_t rxPackets = INVALID_INT64;
230     int64_t txBytes = INVALID_INT64;
231     int64_t rxBytes = INVALID_INT64;
232     if (appDetailWifi.has_tx_packets()) {
233         txPackets = appDetailWifi.tx_packets();
234     }
235     if (appDetailWifi.has_rx_packets()) {
236         rxPackets = appDetailWifi.rx_packets();
237     }
238     if (appDetailWifi.has_tx_bytes()) {
239         txBytes = appDetailWifi.tx_bytes();
240     }
241     if (appDetailWifi.has_rx_bytes()) {
242         rxBytes = appDetailWifi.rx_bytes();
243     }
244     traceDataCache_->GetXPowerAppDetailWifiInfo()->AppendNewAppDetailWifiData(timestamp, txPackets, rxPackets, txBytes,
245                                                                               rxBytes);
246 }
247 
ProcessAppDetailDisplay(const ProtoReader::BytesView & bytesView,uint64_t timestamp)248 void PbreaderXpowerParser::ProcessAppDetailDisplay(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
249 {
250     ProtoReader::AppDetailDisplay_Reader appDetailDisplay(bytesView);
251     XPowerAppDetailDisplayRow row;
252     row.startTime = timestamp;
253     if (appDetailDisplay.has_count_1hz()) {
254         row.count1Hertz = appDetailDisplay.count_1hz();
255     }
256     if (appDetailDisplay.has_count_5hz()) {
257         row.count5Hertz = appDetailDisplay.count_5hz();
258     }
259     if (appDetailDisplay.has_count_10hz()) {
260         row.count10Hertz = appDetailDisplay.count_10hz();
261     }
262     if (appDetailDisplay.has_count_15hz()) {
263         row.count15Hertz = appDetailDisplay.count_15hz();
264     }
265     if (appDetailDisplay.has_count_24hz()) {
266         row.count24Hertz = appDetailDisplay.count_24hz();
267     }
268     if (appDetailDisplay.has_count_30hz()) {
269         row.count30Hertz = appDetailDisplay.count_30hz();
270     }
271     if (appDetailDisplay.has_count_45hz()) {
272         row.count45Hertz = appDetailDisplay.count_45hz();
273     }
274     if (appDetailDisplay.has_count_60hz()) {
275         row.count60Hertz = appDetailDisplay.count_60hz();
276     }
277     if (appDetailDisplay.has_count_90hz()) {
278         row.count90Hertz = appDetailDisplay.count_90hz();
279     }
280     if (appDetailDisplay.has_count_120hz()) {
281         row.count120Hertz = appDetailDisplay.count_120hz();
282     }
283     if (appDetailDisplay.has_count_180hz()) {
284         row.count180Hertz = appDetailDisplay.count_180hz();
285     }
286     traceDataCache_->GetXPowerAppDetailDisplayInfo()->AppendNewAppDetailDisplayData(row);
287 }
288 
ProcessComponentTop(const ProtoReader::BytesView & bytesView,uint64_t timestamp)289 void PbreaderXpowerParser::ProcessComponentTop(const ProtoReader::BytesView &bytesView, uint64_t timestamp)
290 {
291     ProtoReader::ComponentTop_Reader componentTop(bytesView);
292     if (componentTop.has_audio()) {
293         ProcessComponentTopComm(traceDataCache_->GetDataIndex(audioStr_), componentTop.audio(), timestamp);
294     }
295     if (componentTop.has_bluetooth()) {
296         ProcessComponentTopComm(traceDataCache_->GetDataIndex(bluetoothStr_), componentTop.bluetooth(), timestamp);
297     }
298     if (componentTop.has_flashlight()) {
299         ProcessComponentTopComm(traceDataCache_->GetDataIndex(flashlightStr_), componentTop.flashlight(), timestamp);
300     }
301     if (componentTop.has_location()) {
302         ProcessComponentTopComm(traceDataCache_->GetDataIndex(locationStr_), componentTop.location(), timestamp);
303     }
304     if (componentTop.has_wifiscan()) {
305         ProcessComponentTopComm(traceDataCache_->GetDataIndex(wifiscanStr_), componentTop.wifiscan(), timestamp);
306     }
307     if (componentTop.has_display()) {
308         ProcessComponentTopDisplay(traceDataCache_->GetDataIndex(displayStr_), componentTop.display(), timestamp);
309     }
310     if (componentTop.has_gpu()) {
311         ProcessComponentTopDisplay(traceDataCache_->GetDataIndex(gpuStr_), componentTop.gpu(), timestamp);
312     }
313     if (componentTop.has_camera()) {
314         ProcessComponentTopCamera(traceDataCache_->GetDataIndex(cameraStr_), componentTop.camera(), timestamp);
315     }
316     if (componentTop.has_cpu()) {
317         ProcessComponentTopCpu(traceDataCache_->GetDataIndex(cpuStr_), componentTop.cpu(), timestamp);
318     }
319 }
320 
ProcessComponentTopComm(const DataIndex type,const ProtoReader::BytesView & bytesView,uint64_t timestamp)321 void PbreaderXpowerParser::ProcessComponentTopComm(const DataIndex type,
322                                                    const ProtoReader::BytesView &bytesView,
323                                                    uint64_t timestamp)
324 {
325     ProtoReader::ComponentTopCommon_Reader comm(bytesView);
326     XPowerComponentTopRow commRow;
327     commRow.startTime = timestamp;
328     commRow.componentType = type;
329     bool errorInfo = false;
330     auto appname = comm.appname();
331     auto backgroundDuration = comm.background_duration(&errorInfo);
332     auto backgroundEnergy = comm.background_energy(&errorInfo);
333     auto foregroundDuration = comm.foreground_duration(&errorInfo);
334     auto foregroundEnergy = comm.foreground_energy(&errorInfo);
335     auto screenOffDuration = comm.screen_off_duration(&errorInfo);
336     auto screenOffEnergy = comm.screen_off_energy(&errorInfo);
337     auto screenOnDuration = comm.screen_on_duration(&errorInfo);
338     auto screenOnEnergy = comm.screen_on_energy(&errorInfo);
339     while (appname && backgroundDuration && backgroundEnergy && foregroundDuration && foregroundEnergy &&
340            screenOffDuration && screenOffEnergy && screenOnDuration && screenOnEnergy) {
341         commRow.appname = traceDataCache_->GetDataIndex(appname->ToStdString());
342         commRow.backgroundDuration = *backgroundDuration;
343         commRow.backgroundEnergy = *backgroundEnergy;
344         commRow.foregroundDuration = *foregroundDuration;
345         commRow.foregroundEnergy = *foregroundEnergy;
346         commRow.screenOffDuration = *screenOffDuration;
347         commRow.screenOffEnergy = *screenOffEnergy;
348         commRow.screenOnDuration = *screenOnDuration;
349         commRow.screenOnEnergy = *screenOnEnergy;
350         traceDataCache_->GetXPowerComponentTopInfo()->AppendNewComponentTopData(commRow);
351         ++appname;
352         ++backgroundDuration;
353         ++backgroundEnergy;
354         ++foregroundDuration;
355         ++foregroundEnergy;
356         ++screenOffDuration;
357         ++screenOffEnergy;
358         ++screenOnDuration;
359         ++screenOnEnergy;
360     }
361 }
362 
ProcessComponentTopDisplay(const DataIndex type,const ProtoReader::BytesView & bytesView,uint64_t timestamp)363 void PbreaderXpowerParser::ProcessComponentTopDisplay(const DataIndex type,
364                                                       const ProtoReader::BytesView &bytesView,
365                                                       uint64_t timestamp)
366 {
367     ProtoReader::ComponentTopDisplay_Reader display(bytesView);
368     XPowerComponentTopRow displayRow;
369     displayRow.startTime = timestamp;
370     displayRow.componentType = type;
371     bool errorInfo = false;
372     auto appname = display.appname();
373     auto appUsageDuration = display.time(&errorInfo);
374     auto appUsageEnergy = display.energy(&errorInfo);
375     while (appname && appUsageDuration && appUsageEnergy) {
376         displayRow.appname = traceDataCache_->GetDataIndex(appname->ToStdString());
377         displayRow.appUsageDuration = *appUsageDuration;
378         displayRow.appUsageEnergy = *appUsageEnergy;
379         traceDataCache_->GetXPowerComponentTopInfo()->AppendNewComponentTopData(displayRow);
380         ++appname;
381         ++appUsageDuration;
382         ++appUsageEnergy;
383     }
384 }
385 
ProcessComponentTopCamera(const DataIndex type,const ProtoReader::BytesView & bytesView,uint64_t timestamp)386 void PbreaderXpowerParser::ProcessComponentTopCamera(const DataIndex type,
387                                                      const ProtoReader::BytesView &bytesView,
388                                                      uint64_t timestamp)
389 {
390     ProtoReader::ComponentTopCamera_Reader camera(bytesView);
391     XPowerComponentTopRow cameraRow;
392     cameraRow.startTime = timestamp;
393     cameraRow.componentType = type;
394     bool errorInfo = false;
395     auto appname = camera.appname();
396     auto cameraId = camera.camera_id(&errorInfo);
397     auto backgroundDuration = camera.background_duration(&errorInfo);
398     auto backgroundEnergy = camera.background_energy(&errorInfo);
399     auto foregroundDuration = camera.foreground_duration(&errorInfo);
400     auto foregroundEnergy = camera.foreground_energy(&errorInfo);
401     auto screenOffDuration = camera.screen_off_duration(&errorInfo);
402     auto screenOffEnergy = camera.screen_off_energy(&errorInfo);
403     auto screenOnDuration = camera.screen_on_duration(&errorInfo);
404     auto screenOnEnergy = camera.screen_on_energy(&errorInfo);
405     while (appname && cameraId && backgroundDuration && backgroundEnergy && foregroundDuration && foregroundEnergy &&
406            screenOffDuration && screenOffEnergy && screenOnDuration && screenOnEnergy) {
407         cameraRow.appname = traceDataCache_->GetDataIndex(appname->ToStdString());
408         cameraRow.cameraId = *cameraId;
409         cameraRow.backgroundDuration = *backgroundDuration;
410         cameraRow.backgroundEnergy = *backgroundEnergy;
411         cameraRow.foregroundDuration = *foregroundDuration;
412         cameraRow.foregroundEnergy = *foregroundEnergy;
413         cameraRow.screenOffDuration = *screenOffDuration;
414         cameraRow.screenOffEnergy = *screenOffEnergy;
415         cameraRow.screenOnDuration = *screenOnDuration;
416         cameraRow.screenOnEnergy = *screenOnEnergy;
417         traceDataCache_->GetXPowerComponentTopInfo()->AppendNewComponentTopData(cameraRow);
418         ++appname;
419         ++backgroundDuration;
420         ++backgroundEnergy;
421         ++foregroundDuration;
422         ++cameraId;
423         ++foregroundEnergy;
424         ++screenOffDuration;
425         ++screenOffEnergy;
426         ++screenOnDuration;
427         ++screenOnEnergy;
428     }
429 }
430 
ProcessComponentTopCpu(const DataIndex type,const ProtoReader::BytesView & bytesView,uint64_t timestamp)431 void PbreaderXpowerParser::ProcessComponentTopCpu(const DataIndex type,
432                                                   const ProtoReader::BytesView &bytesView,
433                                                   uint64_t timestamp)
434 {
435     ProtoReader::ComponentTopCpu_Reader cpu(bytesView);
436     XPowerComponentTopRow cpuRow;
437     cpuRow.startTime = timestamp;
438     cpuRow.componentType = type;
439     bool errorInfo = false;
440     auto appname = cpu.appname();
441     auto uid = cpu.uid(&errorInfo);
442     auto backgroundDuration = cpu.background_duration(&errorInfo);
443     auto backgroundEnergy = cpu.background_energy(&errorInfo);
444     auto foregroundDuration = cpu.foreground_duration(&errorInfo);
445     auto foregroundEnergy = cpu.foreground_energy(&errorInfo);
446     auto screenOffDuration = cpu.screen_off_duration(&errorInfo);
447     auto screenOffEnergy = cpu.screen_off_energy(&errorInfo);
448     auto screenOnDuration = cpu.screen_on_duration(&errorInfo);
449     auto screenOnEnergy = cpu.screen_on_energy(&errorInfo);
450     auto load = cpu.load(&errorInfo);
451     while (appname && uid && backgroundDuration && backgroundEnergy && foregroundDuration && foregroundEnergy &&
452            screenOffDuration && screenOffEnergy && screenOnDuration && screenOnEnergy && load) {
453         cpuRow.appname = traceDataCache_->GetDataIndex(appname->ToStdString());
454         cpuRow.uid = *uid;
455         cpuRow.backgroundDuration = *backgroundDuration;
456         cpuRow.backgroundEnergy = *backgroundEnergy;
457         cpuRow.foregroundDuration = *foregroundDuration;
458         cpuRow.foregroundEnergy = *foregroundEnergy;
459         cpuRow.screenOffDuration = *screenOffDuration;
460         cpuRow.screenOffEnergy = *screenOffEnergy;
461         cpuRow.screenOnDuration = *screenOnDuration;
462         cpuRow.screenOnEnergy = *screenOnEnergy;
463         cpuRow.load = *load;
464         traceDataCache_->GetXPowerComponentTopInfo()->AppendNewComponentTopData(cpuRow);
465         ++appname;
466         ++backgroundDuration;
467         ++backgroundEnergy;
468         ++uid;
469         ++foregroundDuration;
470         ++foregroundEnergy;
471         ++load;
472         ++screenOffDuration;
473         ++screenOffEnergy;
474         ++screenOnDuration;
475         ++screenOnEnergy;
476     }
477 }
478 } // namespace TraceStreamer
479 } // namespace SysTuning
480