man sprof will give you a full example, including example executable and shared library source code, compilation and linking, environment exports, and sprof commands for final analysis.
man sprof
https://man7.org/linux/man-pages/man1/sprof.1.html