Search code examples
g++profilingprofilergprof

Hide long description of function while profiling with gprof2dot


I use gprof2dot to profile my application:

./gprof2dot.py -f callgrind callgrind.out.x | dot -Tsvg -o output.svg

source

Even though, it gives me beautiful graphical profiling, the name of each function in each box is very long and goes far over screen size. Since boost library has high usage of templates. Just look at one of the function names:

std::reference_wrapper<boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag> > std::ref<boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag> >(boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag>&)

Is there any way to strip out the name space and template and even arguments of the function to make it look smaller in the graph?

PS. The image is very big and I could not convert it into png. I do not know if you can download and open this 10MB image (link).


Solution

  • ./gprof2dot.py has two related options:

    -s, --strip           strip function parameters, template parameters, and
                          const modifiers from demangled C++ function names
    -w, --wrap            wrap function names
    

    I personally prefer -w as I can still tell templates apart.