Skip to content

Profile a program

The profiler runs a run configuration once under the profiler that fits its program, and shows where the time or the memory went, down to the line in the editor. The profiler is Experimental.

Profile a Python program
Editor with forecast.py: the functions harmonic, forecast and high_waters and a main block that forecasts a year and prints the number of high waters
  1. Editor with forecast.py: the functions harmonic, forecast and high_waters and a main block that forecasts a year and prints the number of high waters
  2. The Run tool window shows the program's output, 706 high waters in a year, and Process finished with exit code 0; the run widget at the top now reads forecast.py
  3. The Profiler tool window shows the Call Tree tab: builtins.exec 100 %, then <module>, forecast 95 %, <listcomp>, harmonic 87 %, builtins.sum and <genexpr>, each with total and own share and its file and line; the editor gutter shows milliseconds next to the def lines and the lines with comprehensions
  4. The Flame Graph tab: stacked bars from builtins.exec at the top down to math.cos, the widest bars for forecast, <listcomp> and harmonic, each labelled with its share
  5. The Hot Spots tab lists functions by own time: <genexpr> self 45.7 %, builtins.sum, <listcomp>, math.cos, harmonic and math.radians with their milliseconds and totals

Real frames of the application · ferris-idea drive, then ferris-idea drive screenshot after each step (docs/site/scripts/record-tour.py) · main build of v1.6.0, 2026-12-04 · throwaway Python demo project; theme Ferris IDEA Dark

Ferris IDEA chooses from the configuration’s program and your system; there is no choice to make.

Program CPU Memory What it needs
Python (python, python3, pypy3 with a script) cProfile tracemalloc nothing; the configuration’s own interpreter runs it
Java (java, Maven exec:java, Gradle run) JDK Flight Recorder, a sample every millisecond the allocation samples of the same recording JDK 17 or later, with the jfr tool next to java or in JAVA_HOME
native program, macOS /usr/bin/sample, every millisecond leaks at exit: what was still allocated, by call tree nothing
native program, Linux perf, user space, 1000 samples a second Valgrind Massif, the peak perf or valgrind installed

On Linux, perf must be allowed: when kernel.perf_event_paranoid is above 2, Ferris IDEA says so before it starts and names the command (sudo sysctl kernel.perf_event_paranoid=2); it never changes the setting itself. Profiling on Windows is not available. Kotlin’s own kotlin launcher is not profiled; run the program through java or Gradle run instead.

  1. Select the configuration in the run widget: one from run.toml, or what you ran last, such as a file started with Run Current File (Run configurations).
  2. Choose Run › Profile for time, or Run › Profile Memory. Both are also in the ⋮ menu next to the Run and Debug buttons. On a line with a ▶ for a main, ⌥↩ offers Profile ‘name’ as well.
  3. The before-launch steps run, then the program runs once under the profiler. The status bar says “Profiled name: n ms” when it is done, and the Profiler tool window opens.

The profile ends when the program ends, or when the configuration’s timeout stops it. Only one profile records at a time.

The Profiler tool window (View › Tool Windows › Profiler) has these views; Tab or 1 to 6 switch between them:

View Shows
Call Tree who called whom, with total and own time; → and ← open and close
Hot Spots the functions with the most own time, as a share of the run
Flame Graph callers above callees, wider is more time; frames under 0.5 % and deeper than 32 levels are left out
Timeline (Java) one row per thread over time, with the CPU load; = and - zoom down to a sixteenth, ← → move, 0 shows all
Events (Java) the recording’s events in order
Event Types (Java) each event type with its count; ↩ lists its events
  • Only project code (P) hides frames outside the project.
  • For Java, CPU time, Total time (including waiting) and Allocations (T cycles them) switch what the views count.
  • ↩ or a double-click opens the source at the line. In the Timeline, ↩ opens the call tree of that thread.
  • F5 profiles again; Close removes the profile.

While a profile is shown, the editor shows the cost of each line in the gutter; click a cost to select its function in the call tree. The costs disappear when you edit the file and come back on undo. cProfile measures whole functions, so its costs stand on the lines where a function or a comprehension starts; perf and memory profiles give none.

  1. Run › Attach Profiler to Process…. The Profiler tool window lists your own processes, newest first.
  2. Type to filter and choose one with ↑ ↓.
  3. Press ↩ for ten seconds of CPU samples, or on macOS ⌥↩ for a heap snapshot by class (bytes and count).

On macOS this uses sample and heap, on Linux perf -p, where a heap snapshot is not available. The duration is ten seconds in the window; an agent can choose up to 120.

Only the last profile is kept, in .ferris-idea/profiles/ in the project, with the raw output of the profiler beside it (last.prof, last.jfr, last.sample.txt and so on). A new profile replaces it. There is no search inside a profile, no zoom in the flame graph, and no way to save or open other recordings yet.

  • macOS refuses to sample: allow the app that starts Ferris IDEA under System Settings › Privacy & Security › Developer Tools.
  • “Java memory profiles are not supported yet”: use Profile and the Allocations view of the recording instead.
  • Linux: perf is missing: install linux-perf (Debian), linux-tools-common and linux-tools-generic (Ubuntu) or perf (Fedora, Arch).
  • Python: the configuration is refused: profiling needs a script; python -c and a bare python are not profiled.
  • “A profile is already being recorded”: wait until the running one ends.

Reading the last profile and the process list needs no right; recording needs the right run, and a run configuration also a trusted project. Both record tools do a dry run unless the agent asks otherwise.

  • profile_attachchangesdry run by defaultrunAttach the profiler to one of the user's running processes without restarting it: cpu samples from outside (macOS sample, Linux perf), memory takes a heap snapshot by class (macOS heap).
  • profile_lastreadsThe workspace's last profile (CPU, memory or attached, from the Profiler tool window, profile_run or profile_attach), read from .ferris-idea/profiles/last.json without running anything: engine, unit (samples = milliseconds, or seconds), command, exit code, duration, notes, the 25 hottest functions by self cost with file and line, and the pruned call tree.
  • profile_processesreadsThe user's own processes that the profiler can attach to, newest first: pid, command line and refused with the reason for processes that must not be attached to (JetBrains IDEs are always refused).
  • profile_recordingreadsThe last Java profile's recording; runs nothing.
  • profile_runchangesdry run by defaultruntrusted-projectProfile a run configuration from .ferris-idea/run.toml for CPU (default) or memory: before-launch configurations run normally, then the configuration runs once under a profiler (cProfile/tracemalloc for Python, JDK Flight Recorder for Java, sample/leaks on macOS, perf/Massif on Linux; Java memory refused).