Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Measuring PHP script execution time

To measure script execution time we need to get time when script started, time when ended and do simple math.

To do that we put this code in the beginning of PHP script:

<?php
    $time = microtime();
    $time = explode(' ', $time);
    $start = $time[1] + $time[0];
?>

And this one in the end:

<?php
    $time = microtime();
    $time = explode(' ', $time);
    $end = $time[1] + $time[0];
    $total_time = round(($end - $start), 4);
    echo '<p>PHP execution: '.$total_time.' seconds.</p>'."n";
?>

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus