3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!defined('PHP_INT_MAX')) { $min = -1; do { $last = $min; } while(0 > $min <<= 1); define('PHP_INT_MIN', $last); define('PHP_INT_MAX', ~$last); } class Object { var $___oid = 0, $___ocmp = 0; function Object() { static $counter = 0; if (PHP_INT_MAX === $this->___oid = ++$counter) { $counter = PHP_INT_MIN; } } function __eq($other) { return $this == $other; } function __neq($other) { return !$this->___eq($other); } function __id(&$other) { if (!isset($other->___ocmp) || $this->___ocmp !== $other->___ocmp) { return false; } $this->___ocmp = $this->___ocmp === 1 ? 2 : 1; return $this->___ocmp === $other->___ocmp; } function __nid(&$other) { return !$this->___id($other); } function __lt($other) { return $this < $other; } function __lteq($other) { return $this <= $other; } function __gt($other) { return !$this->___lteq($other); } function __gteq($other) { return !$this->___lt($other); } function __toString() { return "Object #" . $this->___oid . " of type " . get_class($this); } function __toInt() { return $this->___oid; } function __toFloat() { return (float)$this->___oid; } function __toNumber() { return $this->___oid; } function __toArray() { return get_object_vars($this); } function __toBool() { return true; } function __toScalar() { return $this->___oid; } function &__toClass($class) { if (!is_a($this, $class)) { return null; } return $this; } function compare($op, &$other) { static $fMap = array( '==' => '__eq', '!=' => '__neq', '===' => '__id', '!==' => '__nid', '<' => '__lt', '<=' => '__lteq', '>' => '__gt', '>=' => '__gteq', ); if (!isset($fMap[$op])) { trigger_error("Unknown comparison operator: {$op} called from " . $this->getBacktrace(1, 1), E_USER_ERROR); } return call_user_func(array(&$this, $fMap[$op]), $other); } function getBacktrace($firstLevel = 0, $count = null) { $result = array(); foreach (array_slice(debug_backtrace(), 1 + $firstLevel, $count) as $level) { $func = (!empty($level['class']) ? $level['class'] . $level['type'] : '') . (!empty($level['function']) ? $level['function'] . '()' : ''); if (!$func) { $func = 'UNKNOWN'; } $fileLine = !empty($level['file']) ? "{$level['file']}({$level['line']})" : 'UNKNOWN(-1)'; $result[] = "{$fileLine}: {$func}"; } $result[] = "{main}"; if ($count === 1) { return $result[0]; } else if ($count !== null && count($result) > $count) { return array_slice($result, 0, $count); } return $result; } function &castTo($to = 'string') { $methodName = '__to' . $to; if (!method_exists($this, $methodName)) { if (class_exists($to)) { $methodName = '__toClass'; } else { trigger_error("Unknown cast target: {$to} called from " . $this->getBacktrace(1, 1), E_USER_ERROR); } } return call_user_func(array(&$this, $methodName), $to); } } class A extends Object { } $a = new A; $b = new A; var_dump($a->compare('==', $a), $a->compare('==', $b), $a->compare('===', $a), $a->compare('===', $b));

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.0100.00718.43
8.3.50.0100.01121.97
8.3.40.0120.00318.76
8.3.30.0150.00618.88
8.3.20.0040.00420.34
8.3.10.0040.00420.53
8.3.00.0040.00419.26
8.2.180.0040.01516.36
8.2.170.0030.01422.96
8.2.160.0170.00318.91
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00322.17
8.2.110.0060.00320.52
8.2.100.0080.00417.97
8.2.90.0040.00419.05
8.2.80.0000.00917.97
8.2.70.0050.00317.63
8.2.60.0040.00417.68
8.2.50.0060.00318.07
8.2.40.0080.00017.91
8.2.30.0080.00019.24
8.2.20.0080.00017.68
8.2.10.0050.00217.82
8.2.00.0000.00717.64
8.1.280.0130.00325.92
8.1.270.0060.00323.83
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0070.01023.92
8.1.230.0070.00419.04
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.10
8.1.190.0040.00416.97
8.1.180.0060.00318.10
8.1.170.0060.00318.52
8.1.160.0000.00721.96
8.1.150.0040.00418.69
8.1.140.0030.00617.32
8.1.130.0050.00317.64
8.1.120.0040.00317.36
8.1.110.0070.00017.36
8.1.100.0050.00217.30
8.1.90.0070.00017.36
8.1.80.0000.00717.36
8.1.70.0000.00717.30
8.1.60.0060.00317.36
8.1.50.0050.00217.31
8.1.40.0040.00417.40
8.1.30.0040.00417.54
8.1.20.0000.00717.43
8.1.10.0050.00317.39
8.1.00.0040.00417.34
8.0.300.0020.00518.77
8.0.290.0040.00416.63
8.0.280.0070.00018.20
8.0.270.0000.00717.06
8.0.260.0030.00317.13
8.0.250.0040.00417.00
8.0.240.0000.00716.79
8.0.230.0000.00716.94
8.0.220.0040.00416.77
8.0.210.0070.00016.72
8.0.200.0030.00316.83
8.0.190.0030.00616.95
8.0.180.0070.00016.91
8.0.170.0070.00016.77
8.0.160.0030.00316.73
8.0.150.0000.00716.82
8.0.140.0050.00516.78
8.0.130.0080.00013.36
8.0.120.0050.00316.83
8.0.110.0050.00216.83
8.0.100.0040.00416.88
8.0.90.0070.00016.88
8.0.80.0030.01216.89
8.0.70.0040.00416.84
8.0.60.0000.00716.73
8.0.50.0070.00016.83
8.0.30.0140.00917.02
8.0.20.0130.00617.40
8.0.10.0070.00016.74
8.0.00.0030.01316.66
7.4.330.0000.00515.00
7.4.320.0000.00616.55
7.4.300.0000.00716.38
7.4.290.0000.00716.49
7.4.280.0100.00016.41
7.4.270.0000.00716.37
7.4.260.0000.00716.46
7.4.250.0040.00416.21
7.4.240.0020.00516.44
7.4.230.0000.00716.20
7.4.220.0090.00916.44
7.4.210.0030.01016.39
7.4.200.0080.00016.49
7.4.160.0090.00916.54
7.4.150.0150.00317.40
7.4.140.0090.00817.86
7.4.130.0090.00816.40
7.4.120.0140.00316.29
7.4.110.0110.00616.25
7.4.100.0030.01316.46
7.4.90.0090.00916.38
7.4.80.0150.00718.80
7.4.70.0060.01016.19
7.4.60.0110.00716.42
7.4.50.0000.00516.30
7.4.40.0060.00916.20
7.4.30.0070.01016.19
7.4.00.0000.01215.05
7.3.330.0060.00013.11
7.3.320.0030.00313.13
7.3.310.0000.00716.21
7.3.300.0070.00016.23
7.3.290.0100.01016.32
7.3.280.0060.00916.20
7.3.270.0120.00617.40
7.3.260.0100.01016.23
7.3.250.0150.00516.18
7.3.240.0110.00716.10
7.3.230.0030.01316.39
7.3.210.0140.00316.25
7.3.200.0150.00319.39
7.3.190.0060.00916.25
7.3.180.0120.00416.32
7.3.170.0100.00716.29
7.3.160.0040.01216.25
7.3.10.0080.00616.42
7.3.00.0090.00316.61
7.2.330.0090.00916.17
7.2.320.0060.01216.47
7.2.310.0060.01216.32
7.2.300.0100.00716.58
7.2.290.0060.01216.51
7.2.130.0090.00516.70
7.2.120.0050.00716.48
7.2.110.0080.00516.38
7.2.100.0020.01116.28
7.2.90.0040.01316.68
7.2.80.0060.00816.49
7.2.70.0070.00716.41
7.2.60.0080.00616.73
7.2.50.0070.00716.72
7.2.40.0040.00616.70
7.2.30.0060.00916.68
7.2.20.0070.00616.49
7.2.10.0040.00716.60
7.2.00.0100.00516.59
7.1.250.0040.00915.66
7.1.240.0040.00715.81
7.1.230.0060.00315.93
7.1.220.0000.00815.71
7.1.210.0040.01115.87
7.1.200.0030.00815.88
7.1.190.0000.01415.58
7.1.180.0030.01315.92
7.1.170.0000.00915.92
7.1.160.0060.00315.66
7.1.150.0090.00315.93
7.1.140.0070.00315.71
7.1.130.0080.00615.60
7.1.120.0110.00015.89
7.1.110.0030.01015.71
7.1.100.0040.00815.95
7.1.90.0070.00715.82
7.1.80.0000.01415.55
7.1.70.0050.00816.58
7.1.60.0040.00716.57
7.1.50.0080.00816.39
7.1.40.0040.00915.86
7.1.30.0070.00715.88
7.1.20.0050.00516.00
7.1.10.0040.01215.69
7.1.00.0060.03819.17
7.0.330.0030.00915.26
7.0.320.0060.00315.38
7.0.310.0000.01315.53
7.0.300.0050.00215.59
7.0.290.0060.00615.56
7.0.280.0070.00715.22
7.0.270.0040.00815.28
7.0.260.0030.00715.43
7.0.250.0060.00315.19
7.0.240.0100.00315.43
7.0.230.0030.01015.52
7.0.220.0030.00615.48
7.0.210.0060.00615.48
7.0.200.0030.01116.21
7.0.190.0040.00815.23
7.0.180.0040.00415.39
7.0.170.0080.00415.32
7.0.160.0040.01115.68
7.0.150.0090.00315.31
7.0.140.0020.04318.61
7.0.130.0030.01015.35
7.0.120.0090.00015.54
7.0.110.0040.00815.52
7.0.100.0050.02717.82
7.0.90.0030.04117.78
7.0.80.0050.02517.62
7.0.70.0100.02317.77
7.0.60.0070.04317.58
7.0.50.0100.04217.93
7.0.40.0130.03116.68
7.0.30.0090.02516.77
7.0.20.0070.03016.87
7.0.10.0100.04116.84
7.0.00.0130.04216.74
5.6.380.0000.01214.79
5.6.370.0000.00814.76
5.6.360.0140.00014.63
5.6.350.0040.00714.52
5.6.340.0070.00414.50
5.6.330.0100.00314.74
5.6.320.0030.01014.64
5.6.310.0130.00014.48
5.6.300.0030.00514.29
5.6.290.0000.01414.61
5.6.280.0060.04117.72
5.6.270.0070.00714.49
5.6.260.0030.01014.59
5.6.250.0050.04117.52
5.6.240.0060.02617.74
5.6.230.0070.03817.58
5.6.220.0070.04317.61
5.6.210.0100.03817.67
5.6.200.0050.04617.86
5.6.190.0070.02317.73
5.6.180.0070.02917.87
5.6.170.0080.03017.69
5.6.160.0050.04617.63
5.6.150.0100.03817.72
5.6.140.0100.04117.63
5.6.130.0050.04817.78
5.6.120.0100.04717.63
5.6.110.0030.03517.98
5.6.100.0080.04517.79
5.6.90.0070.02817.74
5.6.80.0080.03417.51
5.6.70.0140.03817.44
5.6.60.0060.02617.60
5.6.50.0080.03617.46
5.6.40.0050.04517.45
5.6.30.0070.04317.34
5.6.20.0080.03917.47
5.6.10.0080.04517.30
5.6.00.0100.04217.57
5.5.380.0050.03016.03
5.5.370.0100.04315.92
5.5.360.0090.03816.00
5.5.350.0100.02815.77
5.5.340.0080.04116.13
5.5.330.0120.03916.10
5.5.320.0050.04615.99
5.5.310.0080.04316.17
5.5.300.0050.03816.13
5.5.290.0070.04516.28
5.5.280.0100.04316.13
5.5.270.0080.04716.02
5.5.260.0120.04616.20
5.5.250.0030.04816.16
5.5.240.0060.03315.60
5.5.230.0030.02415.74
5.5.220.0070.03015.82
5.5.210.0100.03515.84
5.5.200.0050.04515.92
5.5.190.0070.04715.69
5.5.180.0040.04915.69
5.5.170.0000.00811.25
5.5.160.0080.03715.75
5.5.150.0070.02515.74
5.5.140.0100.03915.67
5.5.130.0050.04015.72
5.5.120.0090.02815.82
5.5.110.0050.02715.93
5.5.100.0040.04515.66
5.5.90.0030.04215.59
5.5.80.0050.04115.68
5.5.70.0050.04215.60
5.5.60.0030.03415.57
5.5.50.0080.04115.76
5.5.40.0130.03515.71
5.5.30.0070.02415.81
5.5.20.0120.03715.74
5.5.10.0080.03615.73
5.5.00.0070.03015.59
5.4.450.0090.03915.21
5.4.440.0050.03815.44
5.4.430.0030.04315.30
5.4.420.0030.04615.13
5.4.410.0050.03815.09
5.4.400.0030.04215.17
5.4.390.0050.03614.95
5.4.380.0020.03915.10
5.4.370.0010.04115.01
5.4.360.0080.03515.16
5.4.350.0050.03315.14
5.4.340.0070.03015.13
5.4.330.0000.00811.16
5.4.320.0070.03715.18
5.4.310.0060.03815.20
5.4.300.0070.03614.97
5.4.290.0000.04115.16
5.4.280.0140.03315.14
5.4.270.0060.02415.07
5.4.260.0000.04114.97
5.4.250.0070.04015.22
5.4.240.0060.03815.12
5.4.230.0030.04215.15
5.4.220.0070.03715.14
5.4.210.0030.03815.07
5.4.200.0050.04015.24
5.4.190.0050.03315.14
5.4.180.0050.03514.97
5.4.170.0040.02115.11
5.4.160.0000.03315.04
5.4.150.0080.01815.09
5.4.140.0070.02313.89
5.4.130.0070.02713.85
5.4.120.0090.03213.92
5.4.110.0030.04513.72
5.4.100.0030.02513.75
5.4.90.0070.01713.79
5.4.80.0030.02813.80
5.4.70.0020.02113.72
5.4.60.0050.03313.93
5.4.50.0050.02413.90
5.4.40.0020.02513.74
5.4.30.0060.03813.78
5.4.20.0060.03813.88
5.4.10.0050.04113.88
5.4.00.0120.03413.51

preferences:
37.08 ms | 401 KiB | 5 Q