jonc has asked for the wisdom of the Perl Monks concerning the following question:
Hello again and thanks for the continued support,
I am building a CGI script to go online, and it is slow, so I used a profiler to find how to make it better. The problem is, I don't know what I could do...
As you'll see, CGI::AUTOLOAD takes the most time (over half)... What does this mean? Is it something I can control?
Secondly is the File::Find. I tried readdir, but it produced similar results. In the works is eliminating the need to loop through files (by making one large file), I hope this will make it more efficient.
Here is part of the output (I doubt you guys need the whole thing) from one test by Devel::Profile :
time elapsed (wall): 27.9298 time running program: 27.9106 (99.93%) time profiling (est.): 0.0192 (0.07%) number of calls: 4170 %Time Sec. #calls sec/call F name 73.95 20.6410 7 2.948712 CGI::AUTOLOAD 25.48 7.1128 3626 0.001962 <anon>:...Perl/5.10.0/File/Fin +d.pm:717 0.27 0.0746 1 0.074612 File::Find::_find_dir 0.08 0.0216 1 0.021615 <anon>:...bles/mytestsearch201 +1.cgi:25 0.05 0.0142 7 0.002028 CGI::_compile 0.05 0.0131 0 0.013137 * <other> 0.04 0.0113 1 0.011286 <anon>:...y/Perl/5.10.0/CGI/Fa +st.pm:18 0.01 0.0029 1 0.002868 <anon>:...ibrary/Perl/5.10.0/C +GI.pm:27 0.01 0.0025 71 0.000035 main::dependency_checks
And I tried using Devel::FastProf, which gave me this output (-p was used)(Again, only a portion):
/System/Library/Perl/5.10.0/CGI.pm:867 22.53873 1: [at line 10 inside +eval] ??? /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:139 7.02436 11 +7492: next unless ($sentblock =~ /\b$verbform\b/i); ##Ensure the sent +ence contains the searchkey /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:123 0.86092 51 +9: while (my $sentblock = <FILE>) /System/Library/Perl/5.10.0/File/Find.pm:895 0.61021 150: @filenames = + readdir DIR; /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:134 0.22259 29 +373: $sentence =~ s/, / /g; /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:131 0.08909 30 +413: next unless ($sentblock =~ /\[sent. (\d+) len. \d+\]: \[(.+)\]/) +; ##Remember, talking about the whole block here /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:126 0.05230 30 +413: if ( $sentblock =~ /file:\s(\S+)\.txt/) ##Could change to get ju +st chpt number/word /System/Library/Perl/5.10.0/File/Find.pm:940 0.03863 3625: $sub_nlink += (lstat ($no_chdir ? $dir_pref . $FN : $FN))[3]; /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:27 0.03166 1: +require '/Users/jon/Desktop/stanford-postagger-full-2011-04-20/verbTe +nseChanger.pl'; /Library/WebServer/CGI-Executables/mytestsearch2011.cgi:132 0.03129 29 +373: $sentencenumber = $1; ## $1 refers to first set of paranthesis i +n the last match
Hope you can help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Benefiting from Devel::Profile or Devel::FastProf
by locked_user sundialsvc4 (Abbot) on Jun 22, 2011 at 15:42 UTC | |
by locked_user sundialsvc4 (Abbot) on Jun 23, 2011 at 13:17 UTC | |
by jonc (Beadle) on Jun 22, 2011 at 16:04 UTC | |
by Anonymous Monk on Jun 22, 2011 at 16:58 UTC | |
|
Re: Benefiting from Devel::Profile or Devel::FastProf
by 7stud (Deacon) on Jun 23, 2011 at 01:18 UTC |