Skip to content

More Options

p0nce edited this page Dec 19, 2022 · 15 revisions

The Dplug Options in this page are not breaking, and not intended for introducing breaking changes.
They basically change the behaviour of Dplug, are not transitional, and are often used as an aid in development.

They are implemented as version identifiers, like the other Dplug Options.

version(Dplug_ProfileUI)

  • Goal: Produce a flame graph to benchmark your UI.

  • Usage: In your dub.json add "Dplug_ProfileUI" to the list of version identifiers.

    Now the UI context holds a traceProfiler() object that can record events, and does so by default. Every event is recorded for the duration of the session.

    In your UI destructor, put this line:

    version(Dplug_ProfileUI)
    {
        import dplug.core.file;
        writeFile(`/home/myuser/plugin-trace.json`, context.profiler.toBytes());
        browseNoGC("https://ui.perfetto.dev/"); // A webtool to read that trace
    }

    This JSON file can be open in https://ui.perfetto.dev/ or chrome://tracing/ to explore visually the UI CPU consumption.