Tim Starling wrote:
See http://meta.wikimedia.org/wiki/Profiling/20050822 [...] It's much easier to produce user-visible speed improvements by concentrating on relatively rare but slow operations. These often
Good thinking, but your kind of profiling output doesn't support this kind of optimization. At susning.nu I have a log file that reports slow spots and nothing but that. If any page view takes more than 10 seconds, an apology is added to the page footer. It's very easy:
sub TimeLog { my ($text) = @_; my $elapsed = time - $EntryTime; if ($elapsed > 10) { $SlownessExcuse = "<br><b>We are sorry</b> " . "that this page took so long to display.\n" . . "If you have any questions about this, ...\n"; } if ($trace || $elapsed > 4) { my $line = LogTime(time) . " $elapsed $EntryTime $text\n"; open (OUT, ">>$LogDir/time_log"); print OUT $line; close(OUT); $EntryTime = time unless $trace; # reset to avoid repeated alarms } }
Then just sprinkle your code with calls to TimeLog("diff..."). As long as less than 4 seconds have passed since this request was received, these calls cost so little that you can think of them as comments to the source code. If your "time_log" file grows fast, optimize the most commonly called spots first.