in analysis/jfr/src/main/java/org/eclipse/jifa/jfr/JFRAnalyzerImpl.java [175:214]
private void generateCpuTime(DimensionResult<TaskCPUTime> result, List<Object[]> os,
Map<String, Long> names, SymbolMap map, boolean include, List<String> taskSet) {
List<TaskCPUTime> list = result.getList();
for (TaskCPUTime ct : list) {
if (taskSet != null && !taskSet.isEmpty()) {
if (include) {
if (!isTaskNameIn(ct.getTask().getName(), taskSet)) {
continue;
}
} else {
if (isTaskNameIn(ct.getTask().getName(), taskSet)) {
continue;
}
}
}
Map<StackTrace, Long> samples = ct.getSamples();
if (samples != null && !samples.isEmpty()) {
long taskTotalTime = ct.getUser() + ct.getSystem();
AtomicLong sampleCount = new AtomicLong();
samples.values().forEach(sampleCount::addAndGet);
long perSampleTime = taskTotalTime / sampleCount.get();
for (StackTrace s : samples.keySet()) {
Frame[] frames = s.getFrames();
String[] fs = new String[frames.length];
for (int i = frames.length - 1, j = 0; i >= 0; i--, j++) {
fs[j] = frames[i].toString();
}
Object[] o = new Object[3];
o[0] = map.processSymbols(fs);
o[1] = samples.get(s) * perSampleTime;
o[2] = ct.getTask().getName();
os.add(o);
}
names.put(ct.getTask().getName(), taskTotalTime);
}
}
}