Web Content: Calculating Script Execution Times
Web Content Tips - Part 4: If we put attention at google search, we will see that google display execution time of searching and displaying what we search. We can do it with PHP's microtime() function to know how long the script takes:
<?php $start = (float) array_sum(explode(' ',microtime())); // put you code that wanted to render at here $end = (float) array_sum(explode(' ',microtime())); echo "Processing time: ". sprintf("%.4f", ($end-$start))." seconds"; ?>
PHP's microtime() return current UNIX timestamp in microseconds. We compare start and end. The difference between the two is the time taken for script execution.
Tag: web content, execution times Category: PHP Basic Post : April 28th 2008 Read: 2,567
blog comments powered by Disqus