On 8/3/05, Chris Devers <[EMAIL PROTECTED]> wrote:
> On Wed, 3 Aug 2005, 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.
> 
> Did you not see Benchmark.pm on CPAN then? It should be your first step.
> 
>     http://search.cpan.org/perldoc?Benchmark
> 
> After that, a general search for 'benchmark' may also help.
> 
>     http://search.cpan.org/search?query=Benchmark&mode=all
> 
> That turns up several more possibilities, but Benchmark.pm is the one
> you should start with, not least because it is bundled with Perl itself,
> so you shouldn't have to install anything extra to run it.

That depends on what you want to benchmark. Benchmark.pm will
benchmark your script, or parts of your script. It won't, though, help
you benchmark and optimize your MySQL your queries because--assuming
you're not going to hack DBD::MySQL yourself to insert benchmarking
hooks--your benchmarked numbers will include module and connection
overhead.

Actually, this is as it should be: Perl provides ways to access
databases, nothing more. A query doesn't execute differently if it's
called from DBD::MySQL than if it's called from the mysql command line
client. All MySQL sees is "select * from a.a"; it doesn't know whether
than query came from DBD::MySQL, the mysql command line, or a php
script. And it doesn't care. You should come to your perl script with
your SQL already debugged and optimized; debugging one language from
within embedded calls in another is asking for all kinds of trouble.

The best way to benchmark queries is from the command line, or
phpmyAdmin, which is designed for this. You can also use MySQL
Administrator and the Query Browser for this (I think). In any case,
you're looking for an application, not a feature of the programming
language.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to