We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

kotnik on 05/04/07


Tagged

php time


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

zingo
vali29
JimiJay


php code exution time


Published in: PHP 


This code is based on the ASP script posted by Lio. It will determine the time taken for a php script to execute correct to 0.000000000000001 seconds.

  1. // put this at the top of the page
  2. $mtime = microtime();
  3. $mtime = explode(" ",$mtime);
  4. $mtime = $mtime[1] + $mtime[0];
  5. $starttime = $mtime;
  6.  
  7. // put other code and html in here
  8.  
  9. // put this code at the bottom of the page
  10. $mtime = microtime();
  11. $mtime = explode(" ",$mtime);
  12. $mtime = $mtime[1] + $mtime[0];
  13. $endtime = $mtime;
  14. $totaltime = ($endtime - $starttime);
  15. echo "This page was created in ".$totaltime." seconds";

Report this snippet 

You need to login to post a comment.