Zentara wrote:
On Wed, 3 Aug 2005 03:00:01 -0700, [EMAIL PROTECTED] (Sara) wrote:
I have to test/optimize a script on a shared server. The script contains a
couple of mySQL queries etc.
Is there a way that I can see the query execution time (like in phymyAdmin) and total script execution time, plus memory & CPU usage? There are a lot of ways doing it in PHP but nothing in PERL/CGI?
I searched CPAN but failed to find my desired requirements. Are there any
system commands that can be executed within the script to get these values.
TIA.
Sara.
This should give you the idea.
#!/usr/bin/perl -w
sleep 5;
print "This script took ". (time - $^T) .
" seconds in Perl $] on $^O\n";
If you want to test just subs, get a start time when entering
the sub, and a finish time just before the sub returns. Take the
difference and you should have a pretty good indicator.
use Time::Elapse;
#... some code
Time::Elapse->lapse(my $now);
$now = "processing sub foo"
# call your sub here
foo(@args);
print "Time wasted: $now\n";
$ perl -MTime::Elapse -wle 'Time::Elapse->lapse(my $now = "testing 0"); for \
(1..5) {print $now; $now = "testing $_";} print $now;'
00:00:00.000105 [testing 0]
00:00:00.000053 [testing 1]
00:00:00.000035 [testing 2]
00:00:00.000034 [testing 3]
00:00:00.000033 [testing 4]
00:00:00.000035 [testing 5]
:)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>