Czas wykonywania skryptu

<?php
$timeStart = microtime(true);
//code.....................

$timeEnd = microtime(true);
$executionTime = ($timeEnd - $timeStart);

echo '<h3><b>czas</b> ' . round($executionTime * 1000) . ' milliseconds</h3>';
echo '<h3><b>czas</b> ' . $executionTime . ' mikro</h3>';
echo '<h3><b>czas</b> ' . $executionTime/60 . ' sec</h3>';
<?php
$timeStart = microtime(true);
        
//code

$duration = $endtime - $timeStart;
$hours = (int)($duration/60/60);
$minutes = (int)($duration/60)-$hours*60;
$seconds = $duration-$hours*60*60-$minutes*60;
        
$milliseconds = round($duration * 1000);

echo '<h3><b>czas</b> ' . $milliseconds . ' milliseconds</h3>';
echo '<h3><b>czas</b> ' . number_format((float)$seconds, 2, '.', '') . ' seconds</h3>';
    protected function microtimeFormat($startTime, $format = null, $lng = null)
    {
        $seconds = microtime(true) - $startTime;
        $hours = ($seconds / 3600);
        $minutes = $seconds / 60;

        return [
            'hours' =>  number_format($hours, 4, '.', ''),
            'minutes' => number_format($minutes, 4, '.', ''),
            'seconds' => number_format($seconds, 4, '.', ''),
            'milliseconds' => $seconds * 1000
        ];
    }
Komentarze wyłączone