Return to Snippet

Revision: 15883
at July 20, 2009 10:33 by nicolaspar


Initial Code
<?
session_name('debugtime');
session_start();

if( !empty($_GET['clear']) ){
	$_SESSION['tiempos'] = 0;
	$_SESSION['tiempos_veces'] = 0;
	header('location: '.$_SERVER['PHP_SELF']);
	exit;
}

$m = microtime();


sleep(2); // Code eval


$comienzo = explode(" ", $m);
$final = explode(" ", microtime()); $tiempo = ($final[1] + $final[0]) - ($comienzo[1] - $comienzo[0]); 

echo 'This time generation ', number_format($tiempo,2), ' seconds';

$_SESSION['tiempos'] = $tiempo + (empty($_SESSION['tiempos'] )?0:$_SESSION['tiempos']);
$_SESSION['tiempos_veces'] = empty($_SESSION['tiempos_veces'])?1:1+$_SESSION['tiempos_veces'];

?><br />
Count refresh: <?=$_SESSION['tiempos_veces'];?><br />
Average time: <?=number_format($_SESSION['tiempos']/$_SESSION['tiempos_veces'],2);?> seconds.
<br />
<br />
<hr />
<a href="<?=$_SERVER['PHP_SELF'];?>?clear=1">Restar testing time</a>

Initial URL

                                

Initial Description
How to replace sleep(2), for your PHP code. Ideal testing hosting/dns ping.

Initial Title
PHP debug time response server

Initial Tags
php, debug, server

Initial Language
PHP