phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Content: Calculating Script Execution Times

Tag: web content, execution times   Category: PHP Basic
post: 28 Apr 2008 read: 137


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.




| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting