Skip to content

Profiling Overview

m0rkeulv edited this page Oct 25, 2026 · 4 revisions

The plugin can profile Haxe programs on four targets: HashLink, C++ (hxcpp), AIR and JavaScript in a Chromium-family browser. A profiling run builds your program with the extra settings the profiler needs, starts it and shows the results in the IDE's Profiler tool window. This page explains what the profilers have in common; each target has its own page for setup and details.

Note

Experimental. IntelliJ IDEA Ultimate. The profilers may be incomplete, and feedback is especially welcome. They need IntelliJ IDEA Ultimate: the plugin plugs its profilers into the IDE's own profiler, which is part of Ultimate.

Available profilers

Profiler Target Run configuration How it measures Page
HashLink Profiler HashLink bytecode (.hl) HashLink Application Samples the call stacks of all threads with the profiler built into the HashLink VM. HashLink
hxcpp Profiler C++ HXCPP Application (IntelliJ) Samples the main thread every millisecond with the sampler built into hxcpp. HXCPP
hxcpp Tracy C++ HXCPP Application (IntelliJ) Measures every Haxe function call exactly, with the Tracy client built into hxcpp. HXCPP
Flash Profiler AIR Haxe AIR Application Records the telemetry the AIR runtime sends: call stack samples, frames, memory and GC. Flash and AIR
JavaScript Profiler JavaScript in a browser Haxe Web Browser Drives the V8 sampling profiler of a Chromium-family browser. JavaScript

Each profiler page lists the versions it needs, if any; see also Supported Versions.

Two ways of measuring appear in this table:

  • Sampling: the profiler looks at the call stack at a fixed rate. Time is estimated from how often a function was on the stack, the overhead is low and constant, and a call shorter than the sampling interval can be missed.
  • Instrumentation (hxcpp Tracy only): every function reports when it starts and ends. Times and call counts are exact, but the overhead grows with the number of calls.

Start a profiling run

The quickest way is the Haxe tool window:

  1. Open the Haxe tool window and expand the build file's Actions group.
  2. Right-click Build & run and choose the entry that names the profiler, for example Profile with 'HashLink Profiler'. When more than one profiler fits the target (C++ has two), the entry is called Profile and asks which one to use.
  3. The plugin creates the matching run configuration (or reuses it), builds the program with the profiler's additions and starts it. The Profiler tool window opens a tab for the run.

The profiling entry appears only when the build's target can be profiled, and it is disabled while the IDE is indexing. When the run configuration lacks something the profiler needs, the entry opens the configuration editor first, with a title that says what is missing, for example Profiling Needs a Chromium Browser or Profiling Needs the Compiled Executable. Fill in the field and click the editor's start button, which names the profiler. The Build & run row itself is described in Building and Running.

You can also start a profiling run from the run widget on the main toolbar: select the run configuration, open the widget's menu and choose the entry that names the profiler, for example HashLink Profiler. The entry is unavailable while the IDE is indexing and when the selected configuration does not fit the profiler.

Every profiling run starts a new process. Attaching a profiler to a program that is already running is not supported.

What the plugin adds to the build

A profiling run needs extra compiler defines. The plugin adds them for you when the run configuration builds the program in a Run Haxe action before-launch step. The configurations that Build & run creates have this step; for configurations you create by hand, see The Run Haxe action before-launch step. The build file must be one that the Haxe tool window lists. For Lime, OpenFL and NME builds the plugin passes the same defines in the tool's own syntax.

Profiler Added to the build Added at launch
HashLink Profiler -D hl_profile hl --profile <samples per second>
hxcpp Profiler -D HXCPP_PROFILER -D HXCPP_STACK_TRACE -D HXCPP_TELEMETRY, plus a small startup hook -
hxcpp Tracy -D HXCPP_TELEMETRY -D HXCPP_TRACY -D HXCPP_STACK_TRACE -D HXCPP_STACK_LINE, plus -D HXCPP_TRACY_MEMORY when memory capture is on the port the IDE connects to
Flash Profiler -D advanced-telemetry the AIR runtime starts in debug mode
JavaScript Profiler -D js-source-map -D source-map a new browser instance with its debugging port open

The additions apply only to the profiling build; a normal Run or Debug builds without them. Each profiler page explains what to add yourself when a configuration builds without the Run Haxe action step.

While the program runs

Most profilers stream their data to the IDE while the program runs. The tab in the Profiler tool window then fills in live: the call chart follows the newest data until you move or zoom the view. The HashLink VM writes its profile only when the program ends, so its results appear afterwards.

Profiler Live view When you stop the run from the IDE
HashLink Profiler No The profile is lost. Let the program exit on its own, or write the profile from code first.
hxcpp Profiler Yes What has arrived so far is kept.
hxcpp Tracy Yes What has arrived so far is kept.
Flash Profiler Yes What has arrived so far is kept.
JavaScript Profiler Yes The last segment is collected before the browser closes.

Read the results

Flame Graph, Call Tree and Method List

The tab offers the IDE's standard views: Flame Graph, Call Tree and Method List. They work as they do for Java snapshots; see the JetBrains documentation. A selector at the top switches the measure:

  • CPU Time: time spent in each function. Sampling profilers estimate it from the samples; hxcpp Tracy measures it.
  • Samples: raw sample counts (sampling profilers).
  • Invocations: how often each function was called (hxcpp Tracy only).

The Haxe Profiler tab

Next to the standard views, the Haxe Profiler tab shows the run on a time axis. From top to bottom:

  • A thread selector: the chart shows one thread at a time.
  • An overview strip of the whole run. With frames it shows one bar per frame, so a taller bar is a slower frame. Drag inside the highlighted window to move it, drag its edge to zoom or click outside it to jump.
  • Lanes with data on the same time axis (see below), then the Call chart: one row per call depth, outermost call on top.

A toolbar on the left side holds the zoom and view actions, and a details panel on the right explains what you selected.

The Haxe Profiler tab with its thread selector, overview strip, lanes, call chart, toolbar and details panel

The Haxe Profiler tab with the thread selector (1), the overview strip (2), the lanes (3), the call chart (4), the toolbar (5) and the details panel (6)

Working with the chart:

To Do this
Zoom Use Zoom In and Zoom Out in the toolbar, or hold Ctrl (also on macOS) and turn the mouse wheel.
Move along the time axis Hold Shift and turn the mouse wheel, or use the scroll bar under the chart.
See a call's time range and call stack Click it in the call chart.
Open a function's source Double-click it in the call chart.
See what happened in one frame Click the frame in the Frames lane. The details list the time spent on scripting, rendering, GC and idle, and the busiest functions.
Get statistics for a time range Drag across a lane. Frame and GC lanes show the count, rate, fastest and slowest; curves show the minimum, average and maximum.
Find a function Start typing while the chart has the focus.
Rearrange lanes Drag a lane by the handle on its left edge, or drag the line between lanes to resize them.
Show or hide lanes Use Configure View in the toolbar or in the chart's context menu. Default in that dialog shows the lanes that have data.
Undo your layout changes Right-click the chart and choose Reset to Default Layout.

A profiler often names a source file relative to the folder the program was built in. The plugin looks for it next to the capture file first, so code generated per build, such as Lime's ApplicationMain, opens in the build that made the capture, with that build's defines. For a capture moved out of its build folder, the plugin picks the matching file nearest to it in the project.

The lanes are:

Lane Shows
Frames One span per frame, numbered from the start of the run.
GC Garbage collection.
Memory Heap size over time, for example Heap used and Heap reserved.
GPU memory, GPU load GPU figures your program reports (hxcpp Tracy only).
CPU load Thread activity: how busy the selected thread was over time. hxcpp Tracy can add Process CPU and System CPU (all cores).
Events Marks your program sends (HashLink and hxcpp Tracy).
Call chart The calls of the selected thread over time.

A lane without data starts hidden, unless you chose to show it before. A shown lane without data says No data available. Not every profiler can fill every lane, and some lanes need a define or a call in your code. Each profiler page has a table that says which lane gets its data from where.

Performance hints in the editor

While a Haxe profiling result is open, the editor shows the measured time per function in the gutter of your .hx files, in red when a function takes 5% or more of the run. Hover a value for the details. To hide or show the hints, right-click the gutter and choose Hide Performance Hints or Show Performance Hints.

A performance hint of 2.6 in the editor gutter, with a tooltip giving the share of the run

A performance hint in the gutter, with its details on hover

What each profiler records

HashLink hxcpp Profiler hxcpp Tracy Flash (AIR) JavaScript
Measuring sampling sampling, 1 ms every call sampling, about 1 ms sampling, adjustable
Threads all main thread all main thread the page's main thread
Call counts - - yes - -
Frames with Heaps or your own markers - with your own markers display frames the browser's drawn frames
GC major collections GC time per window collections (needs memory capture) GC time per frame GC time
Memory - heap used and reserved live heap per pool (needs memory capture) heap used and reserved JavaScript heap
CPU load estimated estimated measured, plus process and system CPU estimated estimated
Events yes - yes - -
GPU - - from your own plots - -
Live view - yes yes yes yes

None of the views lists individual object allocations.

Profiler settings

Each profiler is an entry under Settings | Build, Execution, Deployment | Profilers | Haxe Profiler. The Profiler Settings button in the Haxe Profiler tab opens the same page.

Entry Options
HashLink Profiler Samples per second: (default 10000)
hxcpp Profiler none; hxcpp samples every 1 ms
hxcpp Tracy Compression level (0-9):, Capture memory allocations (adds runtime overhead), Collect process CPU (starts the program elevated; Windows and Linux), Tracy protocol:
Flash Profiler none
JavaScript Profiler Sampling interval (µs): (default 1000)

You can add more entries of the same kind on this page, for example a second HashLink entry with a different sampling rate. Every entry shows up as its own profiling choice in the run widget and in the Haxe tool window.

Profile files

Every profiling run that records data leaves a file you can open again later from the Profiler tool window (View | Tool Windows | Profiler). The profilers that stream their data write each run into its own captures/<date>-<time>/ folder, so earlier runs are kept.

Profiler File Location
HashLink Profiler hlprofile.dump the program's working directory; each run replaces the previous file
hxcpp Profiler captures/<date>-<time>/hxcppprofile.hxtsession, plus the hxcpp report hxcppprofile.hxcppprof next to the executable
hxcpp Tracy captures/<date>-<time>/hxcppprofile.hxtsession next to the executable
Flash Profiler captures/<date>-<time>/flashprofile.hxtsession next to the AIR application descriptor
JavaScript Profiler captures/<date>-<time>/jsprofile.hxtsession the content directory of the run configuration, or the project directory when it has none

The Profiler tool window also opens V8 .cpuprofile files, for example a profile saved from Chrome DevTools.

Limitations

  • The profilers are experimental and work only with the run configurations listed above.
  • Profiling always starts with the program; it cannot attach to a running process.
  • The run icon in the gutter of a build's main class offers Run and Debug only; start profiling from the Build & run row or the run widget.
  • For C++, an hxml build gets a Build & run row only when it links an executable for this machine. For other hxml C++ builds, create an HXCPP Application (IntelliJ) configuration yourself; see Profiling HXCPP.
  • AIR applications can be profiled; SWF files run in the standalone Flash Player cannot.
  • JavaScript profiling works in Chromium-family browsers only, not in Firefox and not for Node.js programs.

Clone this wiki locally