Tools for Profiling Erlang Code

The standard Erlang distribution comes with three profiling tools.

  • cprof counts the number of times each function is called. This is a lightweight profiler. Running this on a live system adds from 5 to 10 percent to the system load.

  • fprof displays the time for calling and called functions. Output is to a file. This is suitable for large system profiling in a lab or simulated system. It adds significant load to the system.

  • eprof measures how time is used in Erlang programs. This is a predecessor of fprof, which is suitable for small-scale profiling.

Here’s how you run cprof; we’ll use it to profile the code that we wrote in A SHOUTcast Server:

 
1>​ cprof:start(). %% start the profiler
 
4501
 
2>​ shout:start(). ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.