sprof
Read and display shared object profiling data
TLDR
SYNOPSIS
sprof [option ...] shared-object-path [profile-data-path]
DESCRIPTION
sprof displays a profiling summary for a shared object (shared library) specified as its first command-line argument. The profiling summary is created using previously generated profiling data in the optional second argument. If the profiling data path is omitted, sprof looks for a file named \<soname\>.profile in the current directory.Profiling data is generated by setting the LD_PROFILE environment variable to the soname of the shared library and optionally LD_PROFILE_OUTPUT to a directory for the profile data file. Running any application that loads the library then causes the dynamic linker to collect profiling data automatically.If none of -c, -p, or -q is specified, the default behavior is to display both a flat profile and a call graph.
PARAMETERS
-c, --call-pairs
Print a list of pairs of call paths for the interfaces exported by the shared object, along with the number of times each path is used.-p, --flat-profile
Generate a flat profile of all of the functions in the monitored object, with counts and ticks.-q, --graph
Generate a call graph.-?, --help
Display a summary of command-line options and arguments and exit.--usage
Display a short usage message and exit.-V, --version
Display the program version and exit.
CAVEATS
Only one shared library can be profiled at a time via LD_PROFILE. Do not compile with -pg when using sprof; the gprof profiling flag interferes with sprof and produces zeroes for execution times. sprof is a GNU extension and is not specified by POSIX. Requires glibc 2.5-34 or newer; older versions may fail with missing internal flags.
HISTORY
sprof was written by Ulrich Drepper as part of the GNU C Library (glibc), first appearing around glibc 2.0 in 1997. It was created to fill the gap left by gprof, which cannot profile shared libraries. The profiling data collection is handled by the glibc dynamic linker itself, making sprof unique in its ability to profile shared objects without recompilation.
