Profiling C application

Scott Bennett bennett at
Sat Nov 28 19:22:34 UTC 2020

     On Fri, 27 Nov 2020 19:38:28 -0800 Ihor Antonov <ihor at>

>What can I use on FreeBSD to profile a slow application?
>I have a source code of the application and I can rebuild it if necessary.
>I want to see where (in what functions) application spends most of its 
>time - amount of function calls and duration of each call (per call)
>What tools can you recommend to do this?
     I see you already have one response at least to your question, but
perhaps a simpler one is to use a now ancient BSD UNIX tool called gprof(1),
along with the compiler option -pg.  (See the gprof(1) man page for the
details.)  Note, too, that you may want to link your program to the profiling
versions of system libraries as explained in the man page.

                                  Scott Bennett, Comm. ASMELG, CFIAG
* Internet:   bennett at   *xor*   bennett at  *
* "A well regulated and disciplined militia, is at all times a good  *
* objection to the introduction of that bane of all free governments *
* -- a standing army."                                               *
*    -- Gov. John Hancock, New York Journal, 28 January 1790         *

More information about the freebsd-questions mailing list