How to measure g++ performance?

I am working on an application with some rather interesting build performance issues. If we build on Solaris/Linux x86/AMD64 the build is rather fast, but it takes more than five times as long on our Solaris Sparc servers (single-threaded builds on the workstations, but multi-threaded on the server!). We are looking to gather some information to find out where the major culprits are (eg precompilation, disk I/O, etc); personally, I suspect template instantiation to be the biggest issue.

How do we break-down the build process to get this kind of information? We use g++/gmake/GNU binutils. As far as I can tell, g++ does not have a convenient `output benchmarking information in xml format' option (the nerve!), so I am assuming we would need to kick-off a set of other applications at the start of the build then analyse their data later. I figure we could probably work out the analysis if only we knew what meters we need to be running (and what options to launch them with, when applicable). Can anyone advise?

Is g++ -p -g .... not an option? Profiling answers a lot of questions.

Unless I am misunderstanding the -p option (never used it, so entirely possible), I do not think it would help. I believe that would insert extra code to help analyse the execution of the application, where we are looking to analyse the compilation of it. I suppose it could be used to recompile g++ for the same net effect, but I doubt I would be familiar enough with g++ to interpret the results.

Just looking through man gcc I see:

...
       -Q  Makes the compiler print out each function name as it is compiled,
           and print some statistics about each pass when it finishes.

       -ftime-report
           Makes the compiler print some statistics about the time consumed by
           each pass when it finishes.

       -fmem-report
           Makes the compiler print some statistics about permanent memory
           allocation when it finishes.
1 Like

Ah, they look like they are worth trying out. I skimmed the gcc online manual, but did not notice anything like this. Thanks for the advice!

Well, the manpage is literally the size of a small novel; not easy to skim! :slight_smile: I just searched 'statistic'.