3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Php72 { private static $hashMask; private static $hashOffset; public static function utf8_encode($s) { $s .= $s; $len = strlen($s); for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) { switch (true) { case $s[$i] < "\x80": $s[$j] = $s[$i]; break; case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break; default: $s[$j] = "\xC3"; $s[++$j] = chr(ord($s[$i]) - 64); break; } } return substr($s, 0, $j); } public static function utf8_decode($s) { $s .= ''; $len = strlen($s); for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) { switch ($s[$i] & "\xF0") { case "\xC0": case "\xD0": $c = (ord($s[$i] & "\x1F") << 6) | ord($s[++$i] & "\x3F"); $s[$j] = $c < 256 ? chr($c) : '?'; break; case "\xF0": ++$i; case "\xE0": $s[$j] = '?'; $i += 2; break; default: $s[$j] = $s[$i]; } } return substr($s, 0, $j); } public static function php_os_family() { if ('\\' === DIRECTORY_SEPARATOR) { return 'Windows'; } $map = array( 'Darwin' => 'Darwin', 'DragonFly' => 'BSD', 'FreeBSD' => 'BSD', 'NetBSD' => 'BSD', 'OpenBSD' => 'BSD', 'Linux' => 'Linux', 'SunOS' => 'Solaris', ); return isset($map[PHP_OS]) ? $map[PHP_OS] : 'Unknown'; } public static function spl_object_id($object) { if (null === self::$hashMask) { self::initHashMask(); } return self::$hashMask ^ hexdec(substr(spl_object_hash($object), self::$hashOffset, PHP_INT_SIZE)); } private static function initHashMask() { $obj = (object) array(); self::$hashOffset = 16 - PHP_INT_SIZE; self::$hashMask = -1; // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below $obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush'); foreach (debug_backtrace(\PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) { $frame['line'] = 0; break; } } if (!empty($frame['line'])) { ob_start(); debug_zval_dump($obj); self::$hashMask = (int) substr(ob_get_clean(), 17); } self::$hashMask ^= hexdec(substr(spl_object_hash($obj), self::$hashOffset, PHP_INT_SIZE)); } } echo Php72::spl_object_id(new StdClass()); echo Php72::spl_object_id(new StdClass()); echo Php72::spl_object_id(new StdClass()); echo Php72::spl_object_id(new StdClass());

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)
8.3.60.0150.00717.00
8.3.50.0090.01216.30
8.3.40.0120.00318.79
8.3.30.0120.00318.89
8.3.20.0040.00420.22
8.3.10.0040.00721.90
8.3.00.0040.00420.33
8.2.180.0060.01318.41
8.2.170.0080.00822.96
8.2.160.0090.00920.52
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0130.00021.00
8.2.120.0070.00026.16
8.2.110.0050.00520.32
8.2.100.0040.00818.28
8.2.90.0030.00519.25
8.2.80.0030.00517.97
8.2.70.0040.00817.63
8.2.60.0000.00818.03
8.2.50.0080.00018.10
8.2.40.0050.00320.48
8.2.30.0050.00219.23
8.2.20.0040.00418.15
8.2.10.0080.00018.15
8.2.00.0040.00418.16
8.1.280.0090.01225.92
8.1.270.0050.00222.08
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0040.00420.76
8.1.230.0090.00317.52
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0040.00817.23
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0040.00418.46
8.1.160.0050.00319.09
8.1.150.0030.00520.67
8.1.140.0070.00019.53
8.1.130.0000.00718.84
8.1.120.0000.00717.57
8.1.110.0080.00017.52
8.1.100.0000.00817.37
8.1.90.0040.00417.48
8.1.80.0000.00717.54
8.1.70.0040.00417.49
8.1.60.0030.00517.51
8.1.50.0040.00817.60
8.1.40.0040.00417.43
8.1.30.0060.00317.71
8.1.20.0050.00217.66
8.1.10.0030.00617.51
8.1.00.0040.00417.55
8.0.300.0100.00018.77
8.0.290.0000.00816.75
8.0.280.0070.00018.48
8.0.270.0070.00017.31
8.0.260.0030.00316.92
8.0.250.0040.00417.10
8.0.240.0030.00617.10
8.0.230.0000.00717.03
8.0.220.0000.00717.05
8.0.210.0070.00017.02
8.0.200.0030.00317.06
8.0.190.0030.00616.99
8.0.180.0050.00217.01
8.0.170.0040.00717.01
8.0.160.0040.00417.00
8.0.150.0000.01016.93
8.0.140.0070.00016.96
8.0.130.0060.00013.42
8.0.120.0000.00716.94
8.0.110.0060.00316.86
8.0.100.0000.00717.02
8.0.90.0070.00316.78
8.0.80.0080.01217.05
8.0.70.0000.00816.86
8.0.60.0000.00816.87
8.0.50.0000.00716.89
8.0.30.0090.00917.15
8.0.20.0100.00917.43
8.0.10.0000.00716.98
8.0.00.0040.01416.83
7.4.330.0000.00615.55
7.4.320.0030.00316.52
7.4.300.0000.00716.69
7.4.290.0070.00016.44
7.4.280.0040.00416.55
7.4.270.0020.00516.54
7.4.260.0000.00816.45
7.4.250.0040.00416.58
7.4.240.0040.00416.53
7.4.230.0000.00716.63
7.4.220.0110.00716.56
7.4.210.0030.01216.66
7.4.200.0070.00016.52
7.4.160.0060.00916.40
7.4.150.0110.00717.40
7.4.140.0120.00717.86
7.4.130.0110.01416.71
7.4.120.0120.00916.44
7.4.110.0130.00316.59
7.4.100.0070.01016.40
7.4.90.0070.01416.56
7.4.80.0100.01119.39
7.4.70.0120.00616.66
7.4.60.0090.00916.53
7.4.50.0110.00716.39
7.4.40.0130.01016.59
7.4.30.0100.00716.74
7.4.00.0030.01315.13
7.3.330.0000.00513.29
7.3.320.0060.00013.43
7.3.310.0050.00216.57
7.3.300.0070.00016.35
7.3.290.0050.01116.51
7.3.280.0080.00916.45
7.3.270.0180.00017.40
7.3.260.0160.00416.38
7.3.250.0120.00616.51
7.3.240.0090.00916.52
7.3.230.0110.00616.29
7.3.210.0130.00316.49
7.3.200.0070.01016.35
7.3.190.0170.00416.62
7.3.180.0030.01516.31
7.3.170.0120.00616.28
7.3.160.0090.00916.33
7.2.330.0120.00616.65
7.2.320.0060.01216.82
7.2.310.0130.00316.86
7.2.300.0140.00416.95
7.2.290.0070.01016.57
7.2.90.0100.00316.54
7.2.80.0060.00616.41
7.2.70.0030.01316.99
7.2.60.2590.01016.93
7.2.50.0030.01316.88
7.2.40.0030.00917.14
7.2.30.0130.00317.07
7.2.20.0060.01216.80
7.2.10.0100.00316.97
7.2.00.0030.01616.93
7.1.210.1590.00713.96
7.1.200.0000.01015.66
7.1.190.0030.01015.58
7.1.180.0100.00515.73
7.1.170.0070.00715.72
7.1.160.0060.00515.62
7.1.150.0090.00915.57
7.1.140.0040.01015.92
7.1.130.0030.00915.74
7.1.120.0030.01115.78
7.1.110.0110.00815.80
7.1.100.0040.00715.71
7.1.90.0030.01415.81
7.1.80.0030.00915.82
7.1.70.0070.00715.74
7.1.60.0220.00933.75
7.1.50.0190.00933.68
7.1.40.0130.02233.78
7.1.30.0290.01033.59
7.1.20.0240.01033.70
7.1.10.0050.00815.61
7.1.00.0560.00315.81
7.0.310.0030.00715.30
7.0.300.0080.00515.34
7.0.290.0060.01215.35
7.0.280.0040.01115.45
7.0.270.0070.00415.06
7.0.260.0060.00615.33
7.0.250.0040.01115.30
7.0.240.0100.00715.30
7.0.230.0140.00715.04
7.0.220.0030.01115.26
7.0.210.0110.00615.18
7.0.200.0090.00615.26
7.0.190.0040.01115.46
7.0.180.0150.00015.54
7.0.170.0120.00015.16
7.0.160.0090.00615.26
7.0.150.0090.00315.43
7.0.140.0080.00815.44
7.0.130.0120.00315.38
7.0.120.0100.00715.40
7.0.110.0090.00615.00
7.0.100.0060.00815.42
7.0.90.0000.01115.46
7.0.80.0070.00715.29
7.0.70.0120.00015.35
7.0.60.0030.00815.41
7.0.50.0120.00215.53
7.0.40.0060.00615.41
7.0.30.0070.00715.33
7.0.20.0000.01115.41
7.0.10.0080.00315.26
7.0.00.0000.01215.33

preferences:
41.68 ms | 401 KiB | 5 Q