PHP VERSION: 8.2.18

phpng_into_master_speed_improvement.php

<?php
// speed improvements

ob_start();
$loop  20;
$start microtime(TRUE);
for (
$x 0$x $loop$x++) {
    echo 
$x ' ';
    
// create a meaningless string
    
$a 'This is a very long sentence which really does not say anything of significance';
    
// add something even more meaningless to the meaningless string
    
$a .= rand(09999
       . 
substr($arand(0strlen($a)))
       . 
rand(09999)
       . 
substr($arand(0strlen($a)));
    
$b preg_match('/\w+?(s)\w+\b/'$a);
    
$c password_hash($a $bPASSWORD_BCRYPT, ['cost' => 12]);
    
$d = function () {
            
$m PHP_INT_MAX;
            foreach (
range(1,1000) as $v$m *= $v;
        };
    
$d();
}

$stop microtime(TRUE);

printf("\nStart:  %.8f\nStop:   %.8f\nElapsed: %.8f\n"$start$stop$stop $start);
ob_end_flush();

Output


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 
Start:  1713571672.82316208
Stop:   1713571677.91104388
Elapsed: 5.08788180
SOURCE CODE