3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Creatable { } class FooCreatable implements Creatable { } class BarCreatable implements Creatable { } interface Creator { /** * * @param string $input * @param Creatable $creatable * @return bool */ function tryCreate($input, Creatable &$creatable = null); } class AggregateCreator implements Creator { /** * * @var Creator[] */ private $creators = []; /** * * @param Creator[] $creators */ public function __construct($creators) { $this->creators = $creators; } /** * * @param string $input * @param Creatable $creatable * @return bool */ public function tryCreate($input, Creatable &$creatable = null) { foreach ($this->creators as $creator) { if ($creator->tryCreate($input, $creatable)) { return true; } } return false; } } class FooCreator implements Creator { /** * * @param string $input * @param Creatable $creatable * @return bool */ public function tryCreate($input, Creatable &$creatable = null) { if ($input == 'foo') { $creatable = new FooCreatable; return true; } return false; } } class BarCreator implements Creator { /** * * @param string $input * @param Creatable $creatable * @return bool */ public function tryCreate($input, Creatable &$creatable = null) { if ($input == 'bar') { $creatable = new BarCreatable; return true; } return false; } } $creator = new AggregateCreator([ new FooCreator, new BarCreator, ]); $creatable = null; var_dump($creator->tryCreate('foo', $creatable), $creatable); $creatable = null; var_dump($creator->tryCreate('bar', $creatable), $creatable); $creatable = null; var_dump($creator->tryCreate('qux', $creatable), $creatable);

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.0140.00016.58
8.3.60.0090.00618.56
8.3.50.0220.00721.95
8.3.40.0150.00018.67
8.3.30.0180.00319.05
8.3.20.0030.00520.33
8.3.10.0070.00022.14
8.3.00.0040.00422.32
8.2.180.0090.00616.50
8.2.170.0160.00022.96
8.2.160.0100.00320.47
8.2.150.0070.01124.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0070.00021.00
8.2.110.0070.01420.99
8.2.100.0070.00717.97
8.2.90.0060.00619.24
8.2.80.0030.00517.97
8.2.70.0040.00417.63
8.2.60.0000.00718.03
8.2.50.0030.00518.10
8.2.40.0030.00618.22
8.2.30.0040.00418.05
8.2.20.0050.00317.59
8.2.10.0000.00717.71
8.2.00.0070.00017.79
8.1.280.0150.00625.92
8.1.270.0000.00822.24
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0040.00422.80
8.1.230.0040.00717.64
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0090.00017.35
8.1.190.0040.00417.22
8.1.180.0080.00018.10
8.1.170.0030.00618.66
8.1.160.0000.00822.08
8.1.150.0040.00418.65
8.1.140.0040.00417.37
8.1.130.0070.00017.75
8.1.120.0040.00417.47
8.1.110.0080.00017.51
8.1.100.0030.00517.34
8.1.90.0070.00017.32
8.1.80.0040.00417.50
8.1.70.0040.00417.42
8.1.60.0030.00617.59
8.1.50.0030.00617.52
8.1.40.0000.00717.57
8.1.30.0060.00317.58
8.1.20.0000.00917.63
8.1.10.0000.00817.48
8.1.00.0040.00417.38
8.0.300.0040.00718.77
8.0.290.0000.00816.63
8.0.280.0000.00718.48
8.0.270.0030.00317.13
8.0.260.0000.00816.82
8.0.250.0000.00716.87
8.0.240.0040.00416.86
8.0.230.0050.00316.85
8.0.220.0070.00016.87
8.0.210.0040.00416.86
8.0.200.0000.00616.94
8.0.190.0040.00417.00
8.0.180.0000.00716.84
8.0.170.0080.00016.83
8.0.160.0000.00716.79
8.0.150.0000.00816.82
8.0.140.0030.00616.77
8.0.130.0050.00013.39
8.0.120.0000.00816.87
8.0.110.0040.00416.72
8.0.100.0070.00016.83
8.0.90.0000.00716.76
8.0.80.0090.00616.91
8.0.70.0040.00416.96
8.0.60.0000.00716.96
8.0.50.0000.00816.80
8.0.30.0080.01117.20
8.0.20.0090.00917.40
8.0.10.0020.00516.91
8.0.00.0140.00616.53
7.4.330.0020.00215.00
7.4.320.0040.00416.59
7.4.300.0040.00416.64
7.4.290.0040.00416.63
7.4.280.0070.00016.63
7.4.270.0030.00316.63
7.4.260.0030.00516.57
7.4.250.0050.00316.56
7.4.240.0060.00216.47
7.4.230.0000.00716.61
7.4.220.0030.00316.45
7.4.210.0060.00916.61
7.4.200.0050.00216.69
7.4.190.0050.00316.69
7.4.160.0030.01316.58
7.4.150.0120.00617.40
7.4.140.0070.01217.86
7.4.130.0120.00916.60
7.4.120.0080.01116.51
7.4.110.0120.00616.51
7.4.100.0060.01116.68
7.4.90.0080.00816.57
7.4.80.0090.00919.39
7.4.70.0090.00616.50
7.4.60.0100.00616.48
7.4.50.0000.00616.38
7.4.40.0080.00822.77
7.4.30.0040.01216.53
7.4.00.0050.01115.00
7.3.330.0000.00513.18
7.3.320.0050.00013.32
7.3.310.0030.00616.30
7.3.300.0000.00716.20
7.3.290.0070.00716.23
7.3.280.0100.00816.25
7.3.270.0090.00917.40
7.3.260.0100.00716.62
7.3.250.0070.01016.57
7.3.240.0100.00716.40
7.3.230.0150.00316.71
7.3.210.0090.00916.31
7.3.200.0060.01619.39
7.3.190.0060.01616.41
7.3.180.0110.00716.36
7.3.170.0140.00716.41
7.3.160.0100.00616.52
7.3.120.0040.01114.68
7.3.110.0090.00914.87
7.3.100.0080.00815.06
7.3.90.0040.01015.00
7.3.80.0030.01014.73
7.3.70.0060.00914.87
7.3.60.0060.00814.78
7.3.50.0050.00714.88
7.3.40.0050.00814.84
7.3.30.0050.00714.86
7.3.20.0090.00416.76
7.3.10.0060.00416.70
7.3.00.0090.00616.72
7.2.330.0130.00716.68
7.2.320.0070.01416.80
7.2.310.0150.00416.50
7.2.300.0130.00416.71
7.2.290.0080.00816.69
7.2.250.0070.01015.32
7.2.240.0080.01015.10
7.2.230.0050.01215.01
7.2.220.0050.00915.06
7.2.210.0050.00815.13
7.2.200.0060.00515.28
7.2.190.0050.00715.01
7.2.180.0070.00715.12
7.2.170.0040.00915.09
7.2.00.0060.00819.52
7.1.330.0110.00515.81
7.1.320.0030.00815.87
7.1.310.0070.00415.75
7.1.300.0070.00515.70
7.1.290.0030.01115.87
7.1.280.0080.00415.67
7.1.270.0050.00615.73
7.1.260.0030.01215.74
7.1.100.0060.00618.05
7.1.70.0000.00716.71
7.1.60.0070.01419.82
7.1.50.0140.01016.79
7.1.00.0070.07322.41
7.0.200.0000.01016.80
7.0.140.0030.07321.99
7.0.60.0030.05020.02
7.0.50.0070.08317.90
7.0.40.0070.08720.11
7.0.30.0330.07720.12
7.0.20.0100.05020.26
7.0.10.0330.07720.19
7.0.00.0130.05020.19
5.6.280.0000.07721.12
5.6.210.0030.04020.55
5.6.200.0070.05018.13
5.6.190.0000.04720.49
5.6.180.0170.04720.58
5.6.170.0200.05320.62
5.6.160.0170.07720.46
5.6.150.0030.06018.25
5.6.140.0200.06318.20
5.6.130.0030.09018.19
5.6.120.0100.08321.04
5.6.110.0130.06321.06
5.6.100.0230.06721.00
5.6.90.0070.06320.98
5.6.80.0170.07020.50
5.6.70.0200.07020.39
5.5.350.0070.08320.48
5.5.340.0070.05717.99
5.5.330.0130.06720.21
5.5.320.0330.07320.27
5.5.310.0230.07720.32
5.5.300.0030.08717.98
5.5.290.0030.06318.08
5.5.280.0070.04720.75
5.5.270.0170.07320.66
5.5.260.0030.07020.98
5.5.250.0070.03720.60
5.5.240.0070.08020.27
5.4.450.0730.05719.63
5.4.440.0730.04719.34
5.4.430.0100.06019.42
5.4.420.0100.06319.41
5.4.410.0130.05719.06
5.4.400.0230.07018.70
5.4.390.0300.05318.71
5.4.380.0130.05318.81
5.4.370.0100.03718.77
5.4.360.0030.04318.50
5.4.350.0090.03612.04
5.4.340.0060.03912.03
5.4.320.0030.04012.52
5.4.310.0050.04212.52
5.4.300.0050.04312.52
5.4.290.0050.04012.51
5.4.280.0070.03712.38
5.4.270.0090.03512.38
5.4.260.0080.03812.38
5.4.250.0080.03712.39
5.4.240.0060.03812.38
5.4.230.0050.04412.38
5.4.220.0160.05012.38
5.4.210.0100.03412.38
5.4.200.0080.03712.37
5.4.190.0070.03712.37
5.4.180.0070.03812.37
5.4.170.0080.04212.38
5.4.160.0080.03612.38
5.4.150.0070.03712.38
5.4.140.0060.04112.06
5.4.130.0090.03412.04
5.4.120.0070.03812.01
5.4.110.0080.03612.00
5.4.100.0030.04012.00
5.4.90.0070.03712.00
5.4.80.0060.03912.00
5.4.70.0090.04712.00
5.4.60.0080.03411.99
5.4.50.0060.03712.00
5.4.40.0100.03311.98
5.4.30.0070.03611.98
5.4.20.0130.04111.98
5.4.10.0090.03911.98
5.4.00.0020.04011.47
5.3.290.0060.05012.80
5.3.280.0090.04112.70
5.3.270.0080.04112.72
5.3.260.0050.04312.71
5.3.250.0050.04112.72
5.3.240.0060.04012.72
5.3.230.0080.03912.71
5.3.220.0120.03812.68
5.3.210.0110.05312.68
5.3.200.0070.05412.68
5.3.190.0130.04912.67
5.3.180.0100.05512.67
5.3.170.0080.04712.67
5.3.160.0080.03812.68
5.3.150.0130.04912.67
5.3.140.0070.05212.66
5.3.130.0090.05012.66
5.3.120.0100.06012.66
5.3.110.0070.05512.65
5.3.100.0100.05312.12
5.3.90.0130.04612.08
5.3.80.0130.04412.08
5.3.70.0080.03812.08
5.3.60.0120.04412.07
5.3.50.0100.03612.00
5.3.40.0080.04912.00
5.3.30.0050.04711.96
5.3.20.0080.04811.74
5.3.10.0110.04611.70
5.3.00.0080.04211.70
5.2.170.0030.0369.20
5.2.160.0040.0329.19
5.2.150.0070.0309.20
5.2.140.0070.0309.20
5.2.130.0080.0299.15
5.2.120.0080.0289.15
5.2.110.0080.0359.16
5.2.100.0070.0409.15
5.2.90.0090.0329.14
5.2.80.0070.0359.14
5.2.70.0080.0339.14
5.2.60.0090.0429.10
5.2.50.0050.0459.08
5.2.40.0090.0289.05
5.2.30.0090.0389.02
5.2.20.0090.0349.01
5.2.10.0050.0338.92
5.2.00.0060.0298.79
5.1.60.0040.0258.07
5.1.50.0060.0248.07
5.1.40.0050.0288.05
5.1.30.0070.0318.39
5.1.20.0120.0248.42
5.1.10.0070.0348.16
5.1.00.0060.0318.15
5.0.50.0020.0246.62
5.0.40.0030.0226.48
5.0.30.0050.0326.30
5.0.20.0050.0196.26
5.0.10.0070.0246.25
5.0.00.0050.0366.23
4.4.90.0000.0214.77
4.4.80.0040.0154.76
4.4.70.0040.0154.76
4.4.60.0040.0154.75
4.4.50.0030.0164.77
4.4.40.0040.0254.71
4.4.30.0020.0174.76
4.4.20.0050.0204.85
4.4.10.0050.0154.85
4.4.00.0030.0254.76
4.3.110.0020.0174.67
4.3.100.0020.0164.67
4.3.90.0070.0104.64
4.3.80.0040.0254.58
4.3.70.0030.0164.63
4.3.60.0020.0174.63
4.3.50.0030.0184.63
4.3.40.0110.0314.53
4.3.30.0050.0203.27
4.3.20.0030.0213.25
4.3.10.0030.0213.21
4.3.00.0070.0207.32

preferences:
42.88 ms | 401 KiB | 5 Q