3v4l.org

run code in 300+ PHP versions simultaneously
<?php function realValue($value) { if ( is_string($value) && strpos($value, '"SuperClosure\Serialize"') !== false ){ return 'closure!'; } return $value; } function rand_string($len) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen($chars); $str = null; for ($i = 0; $i < $len; $i++) { $str .= $chars[ rand( 0, $size - 1 ) ]; } return $str; } $records = []; for ($i = 1; $i <= 2000; $i++) { $records[$i] = rand_string(1000); } // Ignore above, just generate a random string with 20,000 records. $read_value = null; $realValue_bench_start = microtime(true); foreach ($records as $record) { $read_value = realValue($record); } $realValue_bench_end = microtime(true); $directAccess_bench_start = microtime(true); foreach ($records as $record) { $read_value = $record; } $directAccess_bench_end = microtime(true); $diffRealValue = $realValue_bench_end - $realValue_bench_start; $diffDirectAccess = $directAccess_bench_end - $directAccess_bench_start; echo("readValue time: $diffRealValue"); echo("\ndirectAccess time: $diffDirectAccess"); echo("\ndifference:" . ($diffRealValue - $diffDirectAccess));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.40.2340.18920.40
7.2.30.4480.32320.41
7.2.20.2060.16320.24
7.2.10.2360.17020.38
7.2.00.3480.17520.52
7.1.160.3110.35419.23
7.1.150.2670.36919.23
7.1.140.4490.45719.05
7.1.130.2190.28719.36
7.1.120.2050.30319.07
7.1.110.3310.35318.41
7.1.100.1780.29018.60
7.1.90.2060.30118.43
7.1.80.2480.33918.62
7.1.70.3740.34117.92
7.1.60.4340.29136.06
7.1.50.2720.26735.80
7.1.40.2260.26935.46
7.1.30.4970.41535.36
7.1.20.2490.27535.19
7.1.10.2460.28417.00
7.1.00.2500.28917.25

preferences:
39.52 ms | 401 KiB | 5 Q