Measure PHP execution time

Measure PHP execution time

Postby mancub » Mon Nov 03, 2008 10:33 am

I have some PHP pages that make calls to a database and I am trying to find out how long these pages take to execute. How can I code this into my PHP pages so I can get a measure of how much processing time it takes to execute mysql.

O0

User avatar
mancub
Newbie
Newbie
 
Posts: 20
Joined: Fri Jan 19, 2007 10:37 am

Re: Measure PHP execution time

Postby Darwin » Mon Nov 03, 2008 10:37 am

To determine the execution time for your php script add the following code to the
top and bottom of your page.


Code: Select all
<!-- this goes at the top of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $starttime = $mtime;
;?>


The rest of your PHP file goes here

Code: Select all
<!-- put this code at the bottom of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $endtime = $mtime;
   $totaltime = ($endtime - $starttime);
   echo "This page was created in ".$totaltime." seconds";
;?>

User avatar
Darwin
Full Member
Full Member
 
Posts: 111
Joined: Mon Oct 09, 2006 11:16 am
Location: Bradenton, FL


Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest

cron