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:
Minimize the cost of deploying database applications. Advantage Database Server or Microsoft SQL Server – Which One is Right for You? Learn now!
  #1  
Old April 29th, 2002, 04:35 PM
DroppedAtBirth DroppedAtBirth is offline
Junior Member
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
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 16 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
Junior Member
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
Junior Member
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


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway