NYTProf v2 – A better perl profiler
Back in August, I was profiling a perl script using Devel::DProf. As Tim Bunce suggested to me at that time, Devel::DProf was old and has some problems; and he has recommended NYTProf v2 as a replacement. I used NYTProf v2 to profile the same script. It helped me quickly pinpoint the bottleneck. This NYTProf v2 profiler is easy to use and has a very nice HTML report of subroutine-calls and times spent on each line/sub/module. For more information on NYTProf v2, you can read
I give the statistics below for the original version and the improved version of the script I was working on.
In the original script, some disk-reading code were called 29001297 times repeatedly, which significantly increased the running time. The script took few minutes to finish.
In the improved script, the disk-reading code was optimized – all the data was loaded at the beginning and stored in several hash variables. This largely reduced the total running time of the script.