Skip to content

Instantly share code, notes, and snippets.

@odo
Last active August 29, 2015 14:13
Show Gist options
  • Save odo/b484f9211638b234b11d to your computer and use it in GitHub Desktop.
Save odo/b484f9211638b234b11d to your computer and use it in GitHub Desktop.

How to use KCachegrind / QCachegrind to visualize Erlang traces

install qcachegrind

brew install qcachegrind

install erlgrind

Trace some Erlang

Fun = fun() ->
  random:seed(erlang:now()),
  list:usort([random:uniform(100) || _ <- lists:seq(1, 1000)])
end,

fprof:trace([start, {file, "/tmp/erl_trace"}, verbose, {procs, self()}]).
Fun()

fprof:trace([stop]).
fprof:profile({file, "/tmp/erl_trace"}).
fprof:analyse({dest, "/tmp/outfile.fprof"}).

Convert trace

~/src/erlgrind/src/erlgrind /tmp/outfile.fprof /tmp/callgrind.out

open with qcachegrind

qcachegrind /tmp/callgrind.out

using fprofx

fprofx basically does the same but removes the call to suspended and lists GC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment