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 SplFixedArray()); var_dump(new StdClass()); var_dump(new SplFixedArray());

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.40.0110.00418.82
8.3.30.0140.00018.63
8.3.20.0080.00021.92
8.3.10.0060.00321.87
8.3.00.0080.00020.39
8.2.170.0100.00622.96
8.2.160.0110.00720.52
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0030.00521.00
8.2.120.0000.00726.35
8.2.110.0100.00019.45
8.2.100.0040.00718.18
8.2.90.0050.00319.00
8.2.80.0040.00418.15
8.2.70.0060.00317.75
8.2.60.0050.00317.93
8.2.50.0040.00418.10
8.2.40.0040.00420.42
8.2.30.0000.00719.29
8.2.20.0040.00418.15
8.2.10.0030.00618.07
8.2.00.0030.00518.21
8.1.270.0030.00622.07
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0030.00622.57
8.1.230.0110.00417.42
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0060.00317.48
8.1.190.0040.00417.36
8.1.180.0040.00418.10
8.1.170.0000.00818.64
8.1.160.0070.00019.07
8.1.150.0080.00020.64
8.1.140.0040.00419.66
8.1.130.0040.00418.84
8.1.120.0040.00417.50
8.1.110.0060.00317.42
8.1.100.0040.00417.48
8.1.90.0040.00417.47
8.1.80.0050.00217.53
8.1.70.0000.00717.49
8.1.60.0030.00617.62
8.1.50.0030.00717.57
8.1.40.0000.00917.55
8.1.30.0000.00817.72
8.1.20.0080.00017.65
8.1.10.0000.00717.58
8.1.00.0020.00517.52
8.0.300.0070.00418.77
8.0.290.0000.00816.88
8.0.280.0030.00318.53
8.0.270.0070.00017.20
8.0.260.0030.00316.91
8.0.250.0030.00317.00
8.0.240.0030.00517.04
8.0.230.0040.00416.95
8.0.220.0000.00716.96
8.0.210.0030.00317.00
8.0.200.0040.00417.11
8.0.190.0080.00416.95
8.0.180.0040.00416.94
8.0.170.0090.00316.92
8.0.160.0050.00217.02
8.0.150.0060.00316.83
8.0.140.0020.00516.98
8.0.130.0060.00013.46
8.0.120.0000.00717.05
8.0.110.0040.00416.86
8.0.100.0040.00416.79
8.0.90.0100.00017.11
8.0.80.0030.01716.96
8.0.70.0000.00717.03
8.0.60.0040.00416.91
8.0.50.0040.00417.03
8.0.30.0110.00917.17
8.0.20.0110.00817.42
8.0.10.0040.00416.99
8.0.00.0110.01116.89
7.4.330.0000.00515.55
7.4.320.0000.00716.65
7.4.300.0000.00716.55
7.4.290.0000.00716.50
7.4.280.0040.00416.55
7.4.270.0070.00016.45
7.4.260.0070.00016.49
7.4.250.0040.00416.64
7.4.240.0000.00816.65
7.4.230.0030.00316.46
7.4.220.0070.01116.67
7.4.210.0000.01416.50
7.4.200.0040.00416.66
7.4.160.0050.01316.70
7.4.150.0130.00317.40
7.4.140.0100.01117.86
7.4.130.0140.01016.43
7.4.120.0070.01516.66
7.4.110.0080.00816.57
7.4.100.0070.01116.57
7.4.90.0090.00916.57
7.4.80.0030.01319.39
7.4.70.0100.00616.55
7.4.60.0110.00716.75
7.4.50.0070.00716.45
7.4.40.0090.00916.59
7.4.30.0060.00916.41
7.4.00.0040.01414.98
7.3.330.0030.00313.46
7.3.320.0000.00613.33
7.3.310.0000.00816.51
7.3.300.0000.00716.48
7.3.290.0080.00916.46
7.3.280.0070.00916.44
7.3.270.0130.01017.40
7.3.260.0140.00416.34
7.3.250.0100.01016.36
7.3.240.0110.00716.41
7.3.230.0180.00316.46
7.3.210.0160.00016.59
7.3.200.0030.01316.54
7.3.190.0120.00316.57
7.3.180.0170.00716.53
7.3.170.0100.00616.43
7.3.160.0090.00916.53
7.2.330.0120.00616.69
7.2.320.0070.01016.84
7.2.310.0040.01716.93
7.2.300.0090.00816.81
7.2.290.0090.01416.61
7.2.90.0150.00014.69
7.2.80.0250.00614.95
7.2.70.0370.00315.02
7.2.60.0200.00015.11
7.2.50.0250.00815.14
7.2.40.0090.00615.23
7.2.30.0120.00815.14
7.2.20.0120.00415.29
7.2.10.0120.00815.20
7.2.00.0070.00715.32
7.1.210.0160.00313.81
7.1.200.0060.01413.85
7.1.190.0060.01313.94
7.1.180.2310.00313.86
7.1.170.0070.00713.79
7.1.160.0880.00413.95
7.1.150.0160.00513.92
7.1.140.0120.00613.75
7.1.130.0060.00814.11
7.1.120.0130.00014.02
7.1.110.3810.01313.96
7.1.100.3450.00613.73
7.1.90.3370.01013.80
7.1.80.3480.00313.95
7.1.70.1170.00713.74
7.1.60.1400.00332.00
7.1.50.1100.01331.87
7.1.40.0880.01631.82
7.1.30.0360.01331.97
7.1.20.0990.00032.06
7.1.10.0080.00813.82
7.1.00.0440.01413.72
7.0.310.0030.01113.36
7.0.300.0090.00613.20
7.0.290.0160.00313.54
7.0.280.0200.01213.48
7.0.270.0590.01513.56
7.0.260.0100.00913.76
7.0.250.3370.00713.76
7.0.240.0440.00013.90
7.0.230.3050.01013.58
7.0.220.2850.00613.61
7.0.210.1430.00013.61
7.0.200.1200.01313.53
7.0.190.1360.00713.86
7.0.180.0570.00813.64
7.0.170.0550.00913.46
7.0.160.0480.00413.59
7.0.150.0950.00613.70
7.0.140.0170.00813.92
7.0.130.1110.00713.53
7.0.120.0920.00013.52
7.0.110.0450.00513.76
7.0.100.0430.00613.77
7.0.90.0150.00713.59
7.0.80.1150.00313.38
7.0.70.0170.00713.68
7.0.60.0160.01013.59
7.0.50.0080.01313.94
7.0.40.0130.01613.36
7.0.30.1030.00013.71
7.0.20.0830.01313.84
7.0.10.0170.01113.71
7.0.00.0610.00313.86

preferences:
53.57 ms | 400 KiB | 5 Q