3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { $key = $v[($v[$v])]; // $v is some kind of weird array $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test(); // start class V implements arrayaccess{ public $closure; public function __construct($test){ $this->closure = function(){ echo 'hello'; // a closure to do stuff }; $this->closure->bindTo($test); } // array access stuff I copied any pasted from http://www.php.net/manual/en/class.arrayaccess.php public function offsetSet($offset, $value) { if (is_null($offset)) { $this->array[] = $value; } else { $this->array[$offset] = $value; } } public function offsetExists($offset) { return isset($this->array[$offset]); } public function offsetUnset($offset) { unset($this->array[$offset]); } public function offsetGet($offset) { $offset = (string) $offset; return isset($this->array[$offset]) ? $this->array[$offset] : null; } } $test->callback = new V($test); // end editing here echo $test->run();

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.70.0070.00716.63
8.3.60.0130.00718.80
8.3.50.0080.01022.17
8.3.40.0060.01519.09
8.3.30.0090.00619.22
8.3.20.0020.00520.30
8.3.10.0090.00621.79
8.3.00.0040.00422.51
8.2.180.0110.00418.42
8.2.170.0090.00622.96
8.2.160.0110.00420.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0000.00817.63
8.2.110.0130.01022.27
8.2.100.0080.00417.93
8.2.90.0040.00419.17
8.2.80.0060.00317.97
8.2.70.0060.00617.75
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0080.00018.34
8.2.30.0030.00918.11
8.2.20.0000.00817.85
8.2.10.0040.00419.50
8.2.00.0040.00417.72
8.1.280.0090.00625.92
8.1.270.0040.00422.19
8.1.260.0000.00826.35
8.1.250.0000.00728.09
8.1.240.0110.00723.88
8.1.230.0080.00420.32
8.1.220.0050.00317.74
8.1.210.0000.01018.77
8.1.200.0030.00717.35
8.1.190.0050.00317.51
8.1.180.0000.00818.10
8.1.170.0050.00518.48
8.1.160.0000.00722.14
8.1.150.0030.00518.71
8.1.140.0070.00017.48
8.1.130.0030.00317.86
8.1.120.0000.00717.55
8.1.110.0070.00017.46
8.1.100.0000.00717.49
8.1.90.0000.00717.42
8.1.80.0050.00317.40
8.1.70.0000.00817.41
8.1.60.0030.00617.66
8.1.50.0000.00717.44
8.1.40.0030.00517.57
8.1.30.0040.00417.56
8.1.20.0080.00017.61
8.1.10.0000.00717.45
8.1.00.0080.00317.53
8.0.300.0080.00018.77
8.0.290.0000.00717.05
8.0.280.0040.00418.47
8.0.270.0030.00317.34
8.0.260.0060.00016.89
8.0.250.0040.00417.06
8.0.240.0030.00717.14
8.0.230.0040.00417.05
8.0.220.0000.00717.00
8.0.210.0030.00316.97
8.0.200.0040.00416.91
8.0.190.0000.00817.09
8.0.180.0080.00017.00
8.0.170.0040.00417.00
8.0.160.0060.00316.97
8.0.150.0080.00017.01
8.0.140.0080.00016.90
8.0.130.0030.00313.46
8.0.120.0000.00916.93
8.0.110.0040.00416.96
8.0.100.0040.00416.95
8.0.90.0040.00417.03
8.0.80.0060.01017.03
8.0.70.0000.00716.89
8.0.60.0000.00717.00
8.0.50.0000.00816.91
8.0.30.0130.01017.23
8.0.20.0050.01317.40
8.0.10.0070.00016.93
8.0.00.0120.00916.74
7.4.330.0060.00015.03
7.4.320.0060.00016.61
7.4.300.0040.00416.65
7.4.290.0000.00816.63
7.4.280.0030.00316.65
7.4.270.0000.00716.54
7.4.260.0080.00016.44
7.4.250.0000.00716.45
7.4.240.0000.00716.55
7.4.230.0030.00316.33
7.4.220.0070.01016.65
7.4.210.0070.01116.70
7.4.200.0070.00016.28
7.4.190.0070.00016.50
7.4.160.0030.01316.54
7.4.150.0130.01017.40
7.4.140.0120.00917.86
7.4.130.0120.00516.63
7.4.120.0070.00916.72
7.4.110.0110.00716.62
7.4.100.0000.02316.60
7.4.90.0140.00316.61
7.4.80.0080.01119.39
7.4.70.0030.01316.61
7.4.60.0160.00016.60
7.4.50.0040.00416.72
7.4.40.0070.00722.77
7.4.30.0070.01016.59
7.4.00.0120.00315.07
7.3.330.0060.00013.26
7.3.320.0000.00513.31
7.3.310.0040.00416.38
7.3.300.0070.00016.26
7.3.290.0100.01016.38
7.3.280.0090.00616.40
7.3.270.0130.00417.40
7.3.260.0110.00716.53
7.3.250.0110.00616.43
7.3.240.0090.00916.50
7.3.230.0120.01216.50
7.3.210.0140.00316.52
7.3.200.0080.00819.39
7.3.190.0070.01116.50
7.3.180.0090.00616.54
7.3.170.0100.01116.49
7.3.160.0060.00916.40
7.3.120.0030.01414.88
7.2.330.0130.00716.89
7.2.320.0100.01016.82
7.2.310.0100.01316.77
7.2.300.0030.01316.64
7.2.290.0120.00316.60
7.2.60.0070.01017.06
7.2.00.0000.01319.29
7.1.200.0000.01115.77
7.1.100.0070.00718.16
7.1.70.0070.00317.17
7.1.60.0110.01419.82
7.1.50.0100.01016.84
7.1.00.0170.06022.51
7.0.200.0030.00716.82
7.0.140.0030.06322.19
7.0.60.0130.06319.85
7.0.50.0000.05017.90
7.0.40.0070.08720.13
7.0.30.0600.06320.34
7.0.20.0300.07020.30
7.0.10.0100.03720.25
7.0.00.0070.04320.30
5.6.280.0030.07320.83
5.6.210.0230.07020.57
5.6.200.0070.03718.19
5.6.190.0030.08720.47
5.6.180.0200.05720.41
5.6.170.0200.05020.44
5.6.160.0030.04020.71
5.6.150.0070.05318.18
5.6.140.0030.04018.21
5.6.130.0030.08318.18
5.6.120.0070.08321.03
5.6.110.0170.07720.91
5.6.100.0030.04021.01
5.6.90.0030.04021.08
5.6.80.0070.08320.39
5.5.350.0300.07320.39
5.5.340.0030.07318.07
5.5.330.0000.05020.57
5.5.320.0370.05720.31
5.5.310.0200.04020.20
5.5.300.0070.04717.95
5.5.290.0030.06718.05
5.5.280.0070.04020.78
5.5.270.0030.04020.77
5.5.260.0100.03320.74
5.5.250.0170.07320.60
5.5.240.0270.07020.27
5.4.450.1370.04719.28
5.4.440.0200.05019.55
5.4.430.1030.04319.38
5.4.420.0330.03719.55
5.4.410.0530.06019.34
5.4.400.0600.04019.00
5.4.390.0870.05019.17
5.4.380.1000.05318.61
5.4.370.1030.05718.58
5.4.360.0930.05718.73
5.4.350.1070.06318.71
5.4.340.0970.06018.52
5.4.320.0060.03912.52
5.4.310.0130.04512.52
5.4.300.0060.03812.52
5.4.290.0070.04112.51
5.4.280.0080.03612.41
5.4.270.0070.07718.75
5.4.260.0070.05718.94
5.4.250.0170.05018.94
5.4.240.0070.05318.80
5.4.230.0130.06718.74
5.4.220.0230.06719.02
5.4.210.0130.05318.95
5.4.200.0030.05718.96
5.4.190.0100.05318.89
5.4.180.0100.07318.73
5.4.170.0170.04718.95
5.4.160.0100.07318.92
5.4.150.0200.06718.88
5.4.140.0070.05016.45
5.4.130.0070.05016.44
5.4.120.0070.04716.31
5.4.110.0130.07016.68
5.4.100.0200.04016.62
5.4.90.0100.04716.51
5.4.80.0070.05016.43
5.4.70.0100.05716.45
5.4.60.0100.05016.44
5.4.50.0070.04716.59
5.4.40.0130.06316.43
5.4.30.0100.06716.39
5.4.20.0130.05016.45
5.4.10.0000.06016.52
5.4.00.0000.06315.85
5.3.290.0070.04112.80
5.3.280.0070.05714.77
5.3.270.0200.07014.67
5.3.260.0330.04714.62
5.3.250.0170.07014.79
5.3.240.0100.07314.76
5.3.230.0130.06314.84
5.3.220.0100.05314.60
5.3.210.0170.05314.75
5.3.200.0130.04714.67
5.3.190.0070.05314.57
5.3.180.0070.05014.76
5.3.170.0070.06714.66
5.3.160.0200.06314.59
5.3.150.0070.07314.60
5.3.140.0100.07314.55
5.3.130.0130.06714.54
5.3.120.0200.04014.55
5.3.110.0200.06314.66
5.3.100.0200.04714.15
5.3.90.0170.06714.10
5.3.80.0070.05314.02
5.3.70.0130.06714.23
5.3.60.0070.04713.92
5.3.50.0000.05714.15
5.3.40.0130.04314.06
5.3.30.0000.06014.15
5.3.20.0030.05313.54
5.3.10.0030.08013.75
5.3.00.0070.05013.75
5.2.170.0100.05711.05
5.2.160.0100.03311.32
5.2.150.0100.04011.23
5.2.140.0070.04311.37
5.2.130.0000.04711.18
5.2.120.0030.04011.20
5.2.110.0070.04011.05
5.2.100.0030.04311.27
5.2.90.0130.03311.06
5.2.80.0070.05311.00
5.2.70.0070.04011.26
5.2.60.0070.06011.14
5.2.50.0030.04311.12
5.2.40.0070.03710.99
5.2.30.0000.04710.95
5.2.20.0130.03311.05
5.2.10.0000.05710.77
5.2.00.0070.05310.68
5.1.60.0030.0339.99
5.1.50.0100.05010.02
5.1.40.0030.0379.98
5.1.30.0030.04010.25
5.1.20.0130.04710.52
5.1.10.0070.04710.09
5.1.00.0030.03710.23
5.0.50.0000.0338.40
5.0.40.0000.0308.34
5.0.30.0030.0408.19
5.0.20.0070.0238.30
5.0.10.0030.0308.11
5.0.00.0100.0478.27
4.4.90.0030.0305.90
4.4.80.0070.0175.85
4.4.70.0030.0205.85
4.4.60.0070.0275.85
4.4.50.0000.0305.85
4.4.40.0000.0435.84
4.4.30.0030.0235.80
4.4.20.0070.0305.86
4.4.10.0100.0235.91
4.4.00.0000.0335.88
4.3.110.0000.0235.85
4.3.100.0070.0275.89
4.3.90.0070.0175.77
4.3.80.0130.0305.75
4.3.70.0070.0175.71
4.3.60.0030.0205.72
4.3.50.0100.0205.75
4.3.40.0000.0375.74
4.3.30.0030.0205.61
4.3.20.0030.0235.61
4.3.10.0070.0205.61
4.3.00.0030.02015.57

preferences:
49.25 ms | 401 KiB | 5 Q