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('===', $b), $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.40.0140.00718.79
8.3.30.0050.00818.96
8.3.20.0040.00420.38
8.3.10.0050.00320.45
8.3.00.0030.00619.25
8.2.170.0140.00322.96
8.2.160.0100.00320.52
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0050.00226.16
8.2.120.0040.00422.18
8.2.110.0060.00320.35
8.2.100.0080.00417.97
8.2.90.0040.00419.09
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0030.00517.67
8.2.50.0060.00318.07
8.2.40.0000.00818.02
8.2.30.0050.00219.32
8.2.20.0070.00017.60
8.2.10.0030.00518.02
8.2.00.0050.00317.50
8.1.270.0030.00623.82
8.1.260.0040.00426.35
8.1.250.0020.00528.09
8.1.240.0070.01023.77
8.1.230.0070.00419.02
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0000.01017.10
8.1.190.0040.00417.22
8.1.180.0040.00418.10
8.1.170.0040.00418.44
8.1.160.0080.00022.01
8.1.150.0040.00418.88
8.1.140.0070.00317.21
8.1.130.0070.00017.84
8.1.120.0030.00417.23
8.1.110.0000.00817.36
8.1.100.0030.00317.24
8.1.90.0030.00317.38
8.1.80.0020.00517.25
8.1.70.0040.00417.23
8.1.60.0030.00617.45
8.1.50.0040.00417.44
8.1.40.0040.00417.23
8.1.30.0040.00417.43
8.1.20.0070.00017.59
8.1.10.0000.00717.27
8.1.00.0080.00017.26
8.0.300.0030.00318.77
8.0.290.0070.00016.63
8.0.280.0000.00718.31
8.0.270.0000.00717.20
8.0.260.0000.00617.02
8.0.250.0070.00016.86
8.0.240.0070.00016.82
8.0.230.0030.00316.86
8.0.220.0070.00016.85
8.0.210.0000.00816.82
8.0.200.0030.00316.91
8.0.190.0040.00416.87
8.0.180.0000.00716.82
8.0.170.0000.00816.84
8.0.160.0040.00416.68
8.0.150.0070.00016.84
8.0.140.0000.01016.80
8.0.130.0060.00013.23
8.0.120.0040.00416.81
8.0.110.0050.00316.86
8.0.100.0040.00416.79
8.0.90.0050.00316.64
8.0.80.0030.01616.89
8.0.70.0040.00416.72
8.0.60.0040.00416.68
8.0.50.0020.00516.89
8.0.30.0170.00317.10
8.0.20.0100.00817.40
8.0.10.0000.00816.96
8.0.00.0070.01316.59
7.4.330.0050.00015.00
7.4.320.0000.00616.32
7.4.300.0000.00616.54
7.4.290.0030.00316.41
7.4.280.0110.00016.38
7.4.270.0040.00416.52
7.4.260.0000.00716.51
7.4.250.0030.00516.35
7.4.240.0040.00416.49
7.4.230.0070.00016.58
7.4.220.0080.01116.57
7.4.210.0070.00716.57
7.4.200.0030.00316.51
7.4.160.0110.00816.38
7.4.150.0100.01317.40
7.4.140.0030.01417.86
7.4.130.0120.00516.47
7.4.120.0090.00716.43
7.4.110.0100.00616.56
7.4.100.0070.01016.20
7.4.90.0090.00916.26
7.4.80.0140.00418.80
7.4.70.0140.00316.51
7.4.60.0100.00616.45
7.4.50.0040.00416.07
7.4.40.0070.01016.27
7.4.30.0100.00716.25
7.4.10.0100.01016.34
7.4.00.0050.01215.31
7.3.330.0000.00613.05
7.3.320.0050.00013.05
7.3.310.0000.00716.27
7.3.300.0040.00416.05
7.3.290.0130.00416.25
7.3.280.0070.00716.19
7.3.270.0160.00817.40
7.3.260.0150.00316.37
7.3.250.0100.00716.22
7.3.240.0130.01016.16
7.3.230.0170.00716.39
7.3.210.0130.00316.36
7.3.200.0110.01119.39
7.3.190.0100.00716.36
7.3.180.0090.00616.26
7.3.170.0100.00716.30
7.3.160.0170.00316.32
7.3.130.0120.00616.15
7.3.120.0040.00816.29
7.3.110.0110.00316.20
7.3.100.0070.01016.35
7.3.90.0030.01316.07
7.3.80.0080.00816.34
7.3.70.0030.01016.11
7.3.60.0040.00816.09
7.3.50.0090.00016.10
7.3.40.0030.00716.20
7.3.30.0120.00616.14
7.3.20.0060.00618.11
7.3.10.0100.00817.00
7.3.00.0130.00516.92
7.2.330.0100.00716.34
7.2.320.0060.01616.13
7.2.310.0040.01416.47
7.2.300.0080.00816.40
7.2.290.0080.00816.25
7.2.260.0060.01316.32
7.2.250.0140.00316.40
7.2.240.0100.00716.17
7.2.230.0030.01316.08
7.2.220.0030.01716.28
7.2.210.0040.01216.25
7.2.200.0000.01316.29
7.2.190.0030.00916.42
7.2.180.0030.01016.11
7.2.170.0090.00316.23
7.2.160.0030.00916.32
7.2.150.0090.00318.08
7.2.140.0040.01118.24
7.2.130.0070.00817.12
7.2.120.0130.00617.25
7.2.110.0100.00317.28
7.2.100.0100.01017.20
7.2.90.0080.00516.98
7.2.80.0090.00817.42
7.2.70.0150.00317.21
7.2.60.0110.00717.11
7.2.50.0080.00617.34
7.2.40.0040.01016.99
7.2.30.0130.00717.30
7.2.20.0110.00517.14
7.2.10.0060.01516.91
7.2.00.0100.00618.08
7.1.330.0100.01017.46
7.1.320.0060.01017.37
7.1.310.0070.00417.73
7.1.300.0000.00917.32
7.1.290.0060.00617.54
7.1.280.0090.00317.34
7.1.270.0040.00717.41
7.1.260.0030.00617.32
7.1.250.0150.00416.46
7.1.240.0030.00617.32
7.1.230.0040.00817.23
7.1.220.0130.00617.38
7.1.210.0100.00717.21
7.1.200.0060.00616.58
7.1.190.0080.00817.33
7.1.180.0000.01217.17
7.1.170.0060.01017.38
7.1.160.0090.00617.15
7.1.150.0030.00617.27
7.1.140.0000.00917.20
7.1.130.0070.01117.31
7.1.120.0060.00317.10
7.1.110.0000.01417.32
7.1.100.0030.00917.73
7.1.90.0040.00717.37
7.1.80.0070.00717.26
7.1.70.0030.00817.13
7.1.60.0090.00918.28
7.1.50.0070.01117.08
7.1.40.0080.00817.32
7.1.30.0040.00817.48
7.1.20.0030.01017.34
7.1.10.0070.00717.40
7.1.00.0020.04619.96
7.0.330.0000.01317.07
7.0.320.0030.01016.88
7.0.310.0000.01216.99
7.0.300.0100.00016.94
7.0.290.0000.01217.11
7.0.280.0030.01017.03
7.0.270.0070.00717.02
7.0.260.0120.00317.04
7.0.250.0080.00817.05
7.0.240.0060.00617.00
7.0.230.0080.00416.98
7.0.220.0030.01217.04
7.0.210.0120.00417.09
7.0.200.0040.00717.04
7.0.190.0060.00817.04
7.0.180.0000.01117.02
7.0.170.0110.00416.91
7.0.160.0040.00416.97
7.0.150.0070.00617.18
7.0.140.0020.04219.51
7.0.130.0000.01217.12
7.0.120.0090.00617.05
7.0.110.0060.00917.16
7.0.100.0150.04318.50
7.0.90.0130.04018.49
7.0.80.0050.04618.46
7.0.70.0070.04218.45
7.0.60.0100.03118.44
7.0.50.0070.04318.64
7.0.40.0100.03717.64
7.0.30.0030.03717.47
7.0.20.0030.03317.58
7.0.10.0140.03417.57
7.0.00.0000.03717.48
5.6.400.0070.00716.21
5.6.390.0090.00316.26
5.6.380.0100.00716.03
5.6.370.0030.01016.08
5.6.360.0090.00915.93
5.6.350.0030.01316.09
5.6.340.0060.00916.21
5.6.330.0060.00616.04
5.6.320.0130.00316.02
5.6.310.0030.01016.01
5.6.300.0060.00816.23
5.6.290.0030.01216.23
5.6.280.0030.04318.49
5.6.270.0030.00716.15
5.6.260.0060.00616.32
5.6.250.0090.04218.38
5.6.240.0080.04718.39
5.6.230.0030.04418.37
5.6.220.0100.04218.29
5.6.210.0080.03318.34
5.6.200.0080.03518.64
5.6.190.0050.05218.55
5.6.180.0080.04018.58
5.6.170.0050.05118.54
5.6.160.0050.03918.56
5.6.150.0050.04918.45
5.6.140.0050.05018.68
5.6.130.0020.04218.54
5.6.120.0130.04018.78
5.6.110.0140.04018.64
5.6.100.0120.04218.66
5.6.90.0060.02318.52
5.6.80.0100.03818.31
5.6.70.0070.04318.21
5.6.60.0070.03918.37
5.6.50.0020.02918.20
5.6.40.0130.03318.28
5.6.30.0030.02618.40
5.6.20.0070.02318.27
5.6.10.0100.03518.23
5.6.00.0070.04318.29
5.5.380.0060.03618.29
5.5.370.0100.03218.10
5.5.360.0020.03218.10
5.5.350.0050.04818.25
5.5.340.0020.05118.37
5.5.330.0080.02518.33
5.5.320.0110.04118.52
5.5.310.0070.04318.42
5.5.300.0120.02718.46
5.5.290.0030.03318.43
5.5.280.0110.04118.38
5.5.270.0090.04418.41
5.5.260.0080.04318.47
5.5.250.0070.04318.27
5.5.240.0110.03518.01
5.5.230.0070.04218.11
5.5.220.0000.04818.08
5.5.210.0030.04718.06
5.5.200.0150.03718.09
5.5.190.0020.02818.17
5.5.180.0000.02918.04
5.5.170.0140.00315.51
5.5.160.0050.02718.02
5.5.150.0060.04018.21
5.5.140.0080.03418.19
5.5.130.0050.02718.02
5.5.120.0060.03817.96
5.5.110.0060.04318.03
5.5.100.0020.04518.06
5.5.90.0100.03917.96
5.5.80.0110.03617.95
5.5.70.0100.04018.11
5.5.60.0080.03118.02
5.5.50.0100.03818.01
5.5.40.0120.03317.94
5.5.30.0090.04518.08
5.5.20.0020.05118.03
5.5.10.0070.04317.91
5.5.00.0060.03618.10
5.4.450.0060.04116.09
5.4.440.0030.02815.96
5.4.430.0100.03616.12
5.4.420.0020.04516.02
5.4.410.0070.02115.94
5.4.400.0080.03815.81
5.4.390.0050.03715.88
5.4.380.0070.03815.83
5.4.370.0050.02315.70
5.4.360.0000.03115.71
5.4.350.0050.04515.62
5.4.340.0020.02715.93
5.4.330.0040.01212.50
5.4.320.0100.03715.69
5.4.310.0070.03415.91
5.4.300.0030.02315.75
5.4.290.0070.04015.65
5.4.280.0050.02515.66
5.4.270.0050.04015.78
5.4.260.0020.04215.77
5.4.250.0020.04815.77
5.4.240.0030.04515.75
5.4.230.0040.02915.77
5.4.220.0110.02015.73
5.4.210.0050.02415.68
5.4.200.0030.04315.71
5.4.190.0070.04015.75
5.4.180.0100.02215.78
5.4.170.0030.04015.67
5.4.160.0050.02815.91
5.4.150.0090.02015.92
5.4.140.0050.03714.54
5.4.130.0050.03514.52
5.4.120.0120.03414.58
5.4.110.0070.03214.52
5.4.100.0050.03614.45
5.4.90.0000.04314.52
5.4.80.0050.04414.48
5.4.70.0030.04314.51
5.4.60.0050.03914.49
5.4.50.0080.03714.59
5.4.40.0090.03714.59
5.4.30.0120.03814.66
5.4.20.0030.03614.63
5.4.10.0020.03714.67
5.4.00.0120.03614.30

preferences:
34.79 ms | 400 KiB | 5 Q