Improve efficiency for CpuTimePerUidFreq

Tested on marlin. Shortly after boot, the total is 468 fileds with non
zero time spent at frequency.
It quickly swell to 1600+ though.
It is some improvement compared to 2700+, but still an extremely large
pulled atom.

Bug: 74965273
Test: manual test
Change-Id: Ibbeaa02f54d91c4958d75dd3aaafbb306d61f8d8
This commit is contained in:
Chenjie Yu
2018-03-14 17:12:59 -07:00
parent 35a6c58325
commit 4460e3c22b

View File

@@ -720,11 +720,13 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
long elapsedNanos = SystemClock.elapsedRealtimeNanos();
mKernelUidCpuFreqTimeReader.readAbsolute((uid, cpuFreqTimeMs) -> {
for (int freqIndex = 0; freqIndex < cpuFreqTimeMs.length; ++freqIndex) {
StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 3);
e.writeInt(uid);
e.writeInt(freqIndex);
e.writeLong(cpuFreqTimeMs[freqIndex]);
pulledData.add(e);
if(cpuFreqTimeMs[freqIndex] != 0) {
StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 3);
e.writeInt(uid);
e.writeInt(freqIndex);
e.writeLong(cpuFreqTimeMs[freqIndex]);
pulledData.add(e);
}
}
});
}