I always use the venerable top program in the Terminal to see which program is hogging the CPU. Unfortunately, most of the time it is top itself. Even on a fast 1 GHz dual-processor G4, top can take 20% of the CPU time. On FreeBSD, this is often less than 0.1%. I thought Apple would fix this in subsequent releases of Mac OS X, but I was wrong. It is probably something deeply rooted in the Darwin memory management core that prevents top from being fast, lean and mean.
I am mostly interested in CPU hogs, not in memory usage. Also I always sort on CPU usage, the default behaviour on other OSes. So I made a little shell script to make top use 5 to 10 times fewer CPU cycles. It basically removes all the memory checks from top, so you cannot use it to see how much memory a program occupies, or how much RAM you have left. Use the plain old top for that. This is what I use:
/usr/bin/top -ocpu -R -F -s 2 -n30
It sorts on CPU, it doesn't 'traverse the memory object map,' (a huge time saver), it doesn't calculate library statistics, it only redraws every other second and shows only the first 30 programs. You can put this line in a script called top in your ~/bin/ directory, or make it into an alias. Don't forget to rehash to make it work!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040213045335693