Paulmohr’s Weblog

Open source developer personal weblog

What I have been doing

To see the antfarmgl project blog, use this link.[]

#!/bin/bash rm ants gcc -pg antfarmgl.c sighandler.c afopengl.c listman.c files.c \ -lglut -lGL -lGLU -lm -lasound -ljpeg -lgpm -o ants if [ -e ants ] then ./ants echo "There are ants here!" gprof -b ants gmon.out > results-file.txt kprof -p gprof -f results-file.txt else echo "There are no ants here!" fi

The important thing to notice in “gcc” is the use of the “-gp” option which generates the profile code in “gmon.out” .

I thought I would give this as an example of how to use gprof, gcc, and kprof to profile code for speed. I have used valgrind, ltrace, objdump, nm, strace, xtrace, mtrace, gdb, core analysis ( with ulimit -c 50000), and diagnostics incorporated in the code itself. I think that debugging and code analysis is an absolute necessity in any project. I discovered numerous little things that I did not know even existed. Documentation is another place that must be done right.

Interpretation of the results is a whole separate issue. Years of computer experience have taught me how and where to look and how to interpret the relationships. One interesting thing that I discovered is duplicate calls due to many levels of include. It is difficult to know when things like this happen without the proper tools. So I have a call that calls a library that in turn duplicates a call to an associated function. I would never expect that to happen, but it does.

I can bet that there is some really weird code running around in the Windows world. The reason I think that is because it grows in the dark under pressure and can never be checked. I have done commercial development and I know that I was not allowed to spend the time to do appropriate code testing and analysis, simply because it was extra cost. It can cost twice or even ten times as much to make gospel code. It is worth it to me, as I can easily find flaws in the code, because those thousands of little things that creep into a complex system have been removed proactively.


March 27, 2009 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: