This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.


  Profiling With GCC
  Submitted by

Here's a newbie tip for gcc users, mostly to break the neverending stream of MSVC tips ;).

You can make gcc generate profiling code by passing it the parameter -pg on when both compiling and linking.


gcc -c -pg
gcc mytest.o -pg -o mytest

Then, when you run the program...


...a file called 'gmon.out' will be left in the current directory. This is the stastical data from your programs run. To actually gain something useful from this data you run it through a program called 'gprof'

gprof mytest

This will dump screens and screens of profiling information including a call graph and a flat profile.

Quite helpful for finding those bottlenecks, although interpretation is half the battle.

Alec Thomas

The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.


Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.