Home: Perl Programming Help: DBI:
Number of Queries Executed/Time



andy7t
User

Jun 4, 2004, 9:35 AM


Views: 8407
Number of Queries Executed/Time

Hi,

I want to place something at the bottom of my code which tells me how many MySQL queries where run on the script, and maybe how long it took.

I've seen this done in PHP, but i'd like to know how to do it in Perl.

I'm using the DBI module with MySQL.


davorg
Thaumaturge / Moderator

Jun 8, 2004, 12:55 AM


Views: 8328
Re: [andy7t] Number of Queries Executed/Time


Code
my $start = time; 
my $queries = 0;

# do all of your work, remembering to increment $queries
# each time you execute a query

my $elapsed = time - $start;

print "Executed $queries queries in $elapsed seconds\n";


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


andy7t
User

Jun 8, 2004, 1:46 AM


Views: 8327
Re: [davorg] Number of Queries Executed/Time

Oh.

Is that it. Wink

I thought there may be some command to call from DBI, but that will work just as well.


Thanks

Andrew