1//place this before any script you want to calculate time
2$time_start = microtime(true);
3
4//sample script
5for($i=0; $i<1000; $i++){
6 //do anything
7}
8
9$time_end = microtime(true);
10$execution_time = ($time_end - $time_start);
11echo '<b>Total Execution Time:</b> '.($execution_time*1000).'Milliseconds';
12
1<?php
2
3set_time_limit(20);
4
5while ($i<=10)
6{
7 echo "i=$i ";
8 sleep(100);
9 $i++;
10}
11
12?>
13
14Output:
15i=0 i=1 i=2 i=3 i=4 i=5 i=6 i=7 i=8 i=9 i=10
1//place this before any script you want to calculate time
2$time_start = microtime(true);
3
4//sample script
5for($i=0; $i<1000; $i++){
6 //do anything
7}
8
9$time_end = microtime(true);
10$execution_time = ($time_end - $time_start);
11echo '<b>Total Execution Time:</b> '.($execution_time*1000).'Milliseconds';