|
 |
|
Dev Articles Community Forums
> Programming
> General Programming Help
|
Looking for - Page Generation times Script
Discuss Looking for - Page Generation times Script in the General Programming Help forum on Dev Articles. Looking for - Page Generation times Script General Programming Help forum discussing Perl, Python, Scripting and/or any languages that do not fit into any of the categories above.
|
|
 |
|
|
|

Dev Articles Community Forums Sponsor:
|
|

April 29th, 2002, 05:35 PM
|
Registered User
|
|
Join Date: Apr 2002
Location: Tempe, AZ
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Looking for - Page Generation times Script
I am looking for a good script can calculate the time taken to generate a page, including mysql queries..
Example
Quote:
Page generated in 3.1261730194092 seconds with 30 queries,
spending 2.8116569519043 doing MySQL queries and 0.31451606750488 doing PHP things.
|
I can problably write it myself but why reinvent the wheel if its already been done.
|

April 29th, 2002, 06:48 PM
|
Registered User
|
|
Join Date: Apr 2002
Posts: 15
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
i think this is what you're after: http://www.hotscripts.com/Detailed/13396.html
If not, it's pretty easy to do...just get a timestamp at the start+end of the page as well as before+after any mysql queries, add the differences and bam! you've got a time 
|

April 29th, 2002, 08:02 PM
|
Registered User
|
|
Join Date: Apr 2002
Location: Tempe, AZ
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
That will get me time but not queries count. Also the hotscript link is to a ASP script
|

May 10th, 2002, 02:39 PM
|
Registered User
|
|
Join Date: May 2002
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Well, for the time generation, use something like...
PHP Code:
<?php
$timeparts = explode(" ",microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
// Your script here
$endtime = $timeparts[1].substr($timeparts[0],1);
echo bcsub($endtime,$starttime,6);
?>
For the number of mysql querys, use a variables, and increse it one after every mysql query, and then print it, eg.
PHP Code:
$result = mysql_query("SELECT this FROM that");
$num_querys++;
For the mysql query time, you would have to do something like...
PHP Code:
$timeparts = explode(" ",microtime());
$sqlstart = $timeparts[1].substr($timeparts[0],1);
$result = mysql_query("SELECT this FROM that");
$sqlend = $timeparts[1].substr($timeparts[0],1);
$sql_total += bcsub($endtime,$starttime,6);
echo $sql_total;
Putting that all together...
PHP Code:
<?php
$timeparts = explode(" ",microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
$timeparts = explode(" ",microtime());
$sqlstart = $timeparts[1].substr($timeparts[0],1);
$result = mysql_query("SELECT this FROM that");
$num_querys++;
$sqlend = $timeparts[1].substr($timeparts[0],1);
$sql_total += bcsub($endtime,$starttime,6);
$sql_time = bcsub($endtime,$mysqtime,6);
$endtime = $timeparts[1].substr($timeparts[0],1);
echo 'Page generated in ' . bcsub($endtime,$starttime,6) . 'seconds with ' . $num_querys . 'queries, spending ' . $sqltime . 'doing MySQL querys and ' . $sql_time - $endtime . ' doing PHP things.';
?>
|
Developer Shed Advertisers and Affiliates
Thread Tools |
Search this Thread |
|
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|