Welcome, guest | Sign In | My Account | Store | Cart

In addition for our page we can displaying information how much some page processing spend time occurs by measure script time running. principle is simple with substract time_ending with time_start

PHP, 15 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
### begin page
## this must be write on 1st line before do anything
$_start_time=time();


### your codes begin here.......
##and here .................
##.... until your code ends



## on footer, when process is done we can calculate time with
$_time_spend=time()-$_start_time;

echo "This page needed $_time_spend second";

1 comment

Michal Kočárek 15 years, 6 months ago  # | flag

Why reinventing the wheel?

See php microtime()'s manual entry on http://cz.php.net/microtime, and look for example named "Example #1 Timing script execution with microtime()" or "Example #2 Timing script execution in PHP 5".

It is more accurate, because it returns number of miliseconds as well.

Created by imam ferianto on Mon, 30 Jun 2003 (MIT)
PHP recipes (51)
imam ferianto's recipes (8)

Required Modules

  • (none specified)

Other Information and Tasks