было бы дешевле использовать:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- function getmicrotime()
- {
- return ((float)$usec + (float)$sec);
- }
- $time_start = getmicrotime();
- // вариант 1
- $time_end = getmicrotime();
- $time = $time_end - $time_start;
- $time_start2 = getmicrotime();
- // Вариант 2
- $time_end2 = getmicrotime();
- $time2 = $time_end2 - $time_start2;
- $_SESSION['time2'] += $time2;
- $_SESSION['time'] += $time;
- $_SESSION['count']++;
- echo "For ".$_SESSION['count']." itterations of variant1 took ",$_SESSION['time']," seconds with : ".($_SESSION['time'] / $_SESSION['count'])." average time per itteration <br>";
- echo "For ".$_SESSION['count']." itterations of variant2 took ",$_SESSION['time2']," seconds with : ".($_SESSION['time2'] / $_SESSION['count'])." average time per itteration <br>";
- ?>