1

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).

Community
  • 1
  • 1
barej
  • 1,330
  • 3
  • 25
  • 56
  • My sympathies. I opened the image, and you're right, it's crazy. What's more, most of the boxes are not yours. If I need to find out how to speed up my code, I use [*this method*](http://stackoverflow.com/a/378024/23771). There's no point knowing some library function used a big fraction of time if you can't tell what part of your code caused it. – Mike Dunlavey Feb 10 '15 at 16:53
  • `callgrind.out.x` is just text file, and every function name is stored only for one time in it. You can preprocess it line-by-line with awk or perl. – osgx Mar 03 '15 at 07:32
  • @Mike Dunlavey, are you sure that XY problem exists here and that your poor man profiler (or if you don't like this name, statistical man profiler) should be *marketed* here? (barej already LINKED to the same thread in his question!!) Do you monitor every question tagged `profiler`? – osgx Mar 03 '15 at 07:34
  • @osgx: Marketing? I'm trying to *help* people make their code run as fast as possible, by calling out a very widespread misconception. CPU makers knock themselves out with every trick they can think of to make their chips faster than the competition. Do software people try to do the same? The old but underappreciated technique I'm trying to raise awareness of is a way to shave cycles from software, for those who actually care. What you get with profilers is pretty wallpaper, while the speedups go undiscovered. – Mike Dunlavey Mar 03 '15 at 14:01

1 Answers1

1

./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.

ensonic
  • 3,304
  • 20
  • 31