Re: Profiling applications

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Sat, 03 Feb 2024 07:48:32 UTC
Chuck Tuffli writes:

> What is the recommended way of profiling applications on FreeBSD these days?
> I'm looking for information like '28% of the execution time is spent in function X'.

I would start with basic-block profiling: gcov(1)/llvm-cov(1)

It will not give you the /time/ spent in your functions, but it
will tell you how many times each unbranched sequence of code was
executed.

I personally find that to be much more valuable information than
time spent, because it also reveals a lot about the data being
processed, average operations to find things in trees/lists etc.

Here's an example of that:

	http://varnish-cache.org/gcov/bin/varnishd/cache/cache_esi_parse.c.html

That is from the gcov which is part of Varnish Cache CI:

	http://varnish-cache.org/gcov/

(The python3 scripts to make HTML out of the gcov output are our own and
know a lot about the Varnish source tree, but it can undoubtedly be
adapted.)

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.