/ Gists / Microtime - rychlost měření php kódu
On gists

Microtime - rychlost měření php kódu

PHP

mereni.php Raw #

<?php


function starttime() {
$r = explode( ' ', microtime() );
$r = $r[1] + $r[0];
return $r;
}

function endtime($starttime) {
$r = explode( ' ', microtime() );
$r = $r[1] + $r[0];
$r = round($r - $starttime,4);
return '<strong>Execution Time</strong>: '.$r.' seconds<br />';
}



$start = starttime();

$list = [1,2,3,4,5];

for ($i=0 ; $i< 1e5; $i++) {
    
	if (count($list))
	{
	}
}

echo endtime($start);



$start = starttime();

$list = [1,2,3,4,5];

for ($i=0 ; $i< 1e6; $i++) {
    
	if (!isset($x))
	{
		$x = [];
	}
}

echo endtime($start);