Eventually, you will get to a point where your script's become large, bulky, and long loading. So now you need a method to help you figure out, what is better? to load it this way or that way? Because, we all don't know exactly how efficient every possible function and combination of functions is.
So here is an example of how to measure script execution times
- Code: Select all
<?php
//this is the first half of the script, simply place it where you wish to start measuring the time.
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
- Code: Select all
//After the portion of your script has run, simply add this piece of code;
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4); // i doubt you need it more exact than milliseconds
//in this example, the script is measuring the amount of time it took to search a database and output the results
echo '<p style="font-size: 12px; color: grey;">Search Results Generated in '.$total_time.' seconds.</p>'."\n";
Enjoy.


