General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 29th, 2002, 04:35 PM
DroppedAtBirth DroppedAtBirth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Tempe, AZ
Posts: 14 DroppedAtBirth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to DroppedAtBirth
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.

Reply With Quote
  #2  
Old April 29th, 2002, 05:48 PM
Reg77n Reg77n is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 15 Reg77n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #3  
Old April 29th, 2002, 07:02 PM
DroppedAtBirth DroppedAtBirth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Tempe, AZ
Posts: 14 DroppedAtBirth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to DroppedAtBirth
That will get me time but not queries count. Also the hotscript link is to a ASP script

Reply With Quote
  #4  
Old May 10th, 2002, 01:39 PM
RyanJ RyanJ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 2 RyanJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.';

?>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Looking for - Page Generation times Script


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap