thedoe has asked for the wisdom of the Perl Monks concerning the following question:
I have written a script which is taking quite a bit longer than I expect it to. I had originally thought this was due to interaction with the DB. I just did a DBI profile (using $dbh->{Profile} = 2;), however, and found the queries are taking much less of the overall time than I had believed.
I am therefore trying to find out where exactly the bottleneck is in my program. I have searched on monks and CPAN for things such as performance, profile, benchmark, and bottleneck. I am aware of Benchmark, however it is not quite what I am after. I am not trying to compare different subroutines in my program, I want to run my program like it is normally run and see where it spends most of its time. This includes subsections of subroutines and the main code.
The first thing that comes to mind is something where I am able to manually set different checkpoints within the code using something like labels, and have the time spent in each checkpoint be printed out. Something along the lines of:
A: { ...do things... } B: { ...do some other stuff... } C: { ...why not more stuff here... ...and some more!... }
With the output of this being something along the lines of:
A: 10s B: 2m C: 3s
Does anyone know of something that exists like this, or would it be easiest to simply create multiple new Benchmark objects at the beginning and end of each section and do a timediff on each of them? The biggest problem with this is there could easily be lots of different sections and this would become quite tedious.
Thanks in advance!
Update: So moments after posting this and continuing my search, I finally run across Devel::DProf at the bottom of Benchmark. I am reading through it now to learn how to use it. Any little hints anyone has would be greatly appreciated as well!
Update 2: It seems Devel::DProf is still completely subroutine based. While this looks like a wonderful tool in general, it isn't quite generic enough about portioning off code for me. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: performance profiling
by perrin (Chancellor) on Sep 25, 2006 at 16:36 UTC | |
by thedoe (Monk) on Sep 25, 2006 at 17:01 UTC | |
by madbombX (Hermit) on Sep 25, 2006 at 17:33 UTC | |
|
Re: performance profiling
by grep (Monsignor) on Sep 25, 2006 at 16:31 UTC | |
|
Re: performance profiling
by Tanktalus (Canon) on Sep 25, 2006 at 16:39 UTC | |
by thedoe (Monk) on Sep 25, 2006 at 16:45 UTC | |
|
Re: performance profiling
by shmem (Chancellor) on Sep 25, 2006 at 16:57 UTC |