How do you profile an entire application

Think I figured it out.

Right at the top of my application’s start function, I added:

:fprof.trace([:start, verbose: true, procs: :all])

spawn fn ->
  :timer.sleep(10_000)
  :fprof.trace(:stop)
  :fprof.profile()
  :fprof.analyse(totals: false, dest: 'prof.analysis')
end

the procs: all makes it profile all processes. I stop the trace after 10 second. This generated a 1.5GB fprof.trace file (so, beware!) The calls to profile/analyze generates a very verbose prof.analysis file (37MB). This file can be explored, but it’s noisy.

I used https://github.com/isacssouza/erlgrind to convert the file to a callgrind format which then lets you use those sets of tools (like http://kcachegrind.sourceforge.net/html/Home.html).

9 Likes