Here on the forums somewhere is a profiling class I wrote. Basically at the start of each block of code you want to profile you call a function, at the end the class dumps a record of how long each block took to run.

I cant find the relevant post as "You cannot make another search so soon after your last; please try again in a short while."