Skip to content

bric3/fireplace

Repository files navigation

Java CI with Gradle Maven Central

Flamegraph / Iciclegraph Java Swing component

Shows a flamegraph in either light or dark mode

This flamegraph component is known to be used in JDK Mission Control 9.0 and in the Datadog plugin for IntelliJ.

Usage

Example usage
var fg = new FlamegraphView<Node>();

flamegraphView.setRenderConfiguration(
        FrameTextsProvider.of(
                frame -> frame.isRoot() ? "root" : frame.actualNode.getFrame().getHumanReadableShortString(),
                frame -> frame.isRoot() ? "" : FormatToolkit.getHumanReadable(frame.actualNode.getFrame().getMethod(), false, false, false, false, true, false),
                frame -> frame.isRoot() ? "" : frame.actualNode.getFrame().getMethod().getMethodName()
        ),
        new DimmingFrameColorProvider<>(defaultFrameColorMode.colorMapperUsing(ColorMapper.ofObjectHashUsing(defaultColorPalette.colors()))),
        FrameFontProvider.defaultFontProvider()
);

jpanel.add(flamegraphView.component);


// later, fill in the data
var listOfFrames = FrameBox.flattenAndCalculateCoordinate(new ArrayList<Node>(), ...);
flamegraphView.setModel(
        new FrameModel<>(
                "title, events (CPU, Locks)", // used in the root "frame"
                 (a, b) -> Objects.equals(a, b), // used to identify equal frames
                 listOfFrames
        )
);