in analysis/jfr/src/main/java/org/eclipse/jifa/jfr/JFRAnalyzerImpl.java [89:126]
private FlameGraph createFlameGraph(ProfileDimension dimension, AnalysisResult result, boolean include,
List<String> taskSet) {
List<Object[]> os = new ArrayList<>();
Map<String, Long> names = new HashMap<>();
SymbolMap symbolTable = new SymbolMap();
if (dimension == ProfileDimension.CPU) {
DimensionResult<TaskCPUTime> cpuTime = result.getCpuTime();
generateCpuTime(cpuTime, os, names, symbolTable, include, taskSet);
} else {
DimensionResult<? extends TaskResultBase> DimensionResult = switch (dimension) {
case CPU_SAMPLE -> result.getCpuSample();
case WALL_CLOCK -> result.getWallClock();
case NATIVE_EXECUTION_SAMPLES -> result.getNativeExecutionSamples();
case ALLOC -> result.getAllocations();
case MEM -> result.getAllocatedMemory();
case FILE_IO_TIME -> result.getFileIOTime();
case FILE_READ_SIZE -> result.getFileReadSize();
case FILE_WRITE_SIZE -> result.getFileWriteSize();
case SOCKET_READ_TIME -> result.getSocketReadTime();
case SOCKET_READ_SIZE -> result.getSocketReadSize();
case SOCKET_WRITE_TIME -> result.getSocketWriteTime();
case SOCKET_WRITE_SIZE -> result.getSocketWriteSize();
case SYNCHRONIZATION -> result.getSynchronization();
case THREAD_PARK -> result.getThreadPark();
case CLASS_LOAD_COUNT -> result.getClassLoadCount();
case CLASS_LOAD_WALL_TIME -> result.getClassLoadWallTime();
case THREAD_SLEEP -> result.getThreadSleepTime();
default -> throw new RuntimeException("should not reach here");
};
generate(DimensionResult, os, names, symbolTable, include, taskSet);
}
FlameGraph fg = new FlameGraph();
fg.setData(os.toArray(new Object[0][]));
fg.setThreadSplit(names);
fg.setSymbolTable(symbolTable.getReverseMap());
return fg;
}