3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $c; protected $d; public function set(B $test) { static $testMap = []; if (empty($testMap)) { $testMap = [ C::class => [$this, 'setC'], D::class => [$this, 'setD'], ]; } if ($test === null) { return; } $testType = get_class($test); if (!array_key_exists($testType, $testMap)) { throw new InvalidArgumentException( sprintf( "Encountered unexpected body type (%s) that isn't supported", $testType ) ); } call_user_func($testMap[$testType], $test); } /** * @param C|null $c */ public function setC(C $c = null) { $this->c = $c; } /** * @param D|null $d */ public function setD(D $d = null) { $this->d = $d; } } abstract class B { protected $data; public function __construct($q = '') { $this->data = $q; } } class C extends B { } class D extends B {} $a1 = new A; $a1->set(new C("test c1")); var_dump($a1); $a2 = new A; $a2->set(new C("test c2")); var_dump($a2); $a3 = new A; $a3->set(new C("test c3")); var_dump($a3);

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.63
8.3.60.0170.00318.43
8.3.50.0090.00617.98
8.3.40.0060.01020.46
8.3.30.0090.00618.84
8.3.20.0000.00821.76
8.3.10.0040.00422.15
8.3.00.0050.00322.51
8.2.190.0110.01118.31
8.2.180.0100.01016.50
8.2.170.0140.00322.96
8.2.160.0070.00719.46
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00020.78
8.2.110.0060.00320.47
8.2.100.0080.00417.91
8.2.90.0040.00418.06
8.2.80.0000.00817.97
8.2.70.0000.00817.50
8.2.60.0080.00017.38
8.2.50.0100.00018.05
8.2.40.0040.00419.78
8.2.30.0000.00718.16
8.2.20.0050.00318.16
8.2.10.0040.00419.41
8.2.00.0040.00419.22
8.1.280.0040.01125.92
8.1.270.0090.00022.06
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0000.00822.10
8.1.230.0080.00420.84
8.1.220.0030.00617.74
8.1.210.0040.00418.88
8.1.200.0060.00317.52
8.1.190.0060.00317.22
8.1.180.0080.00318.10
8.1.170.0050.00317.62
8.1.160.0040.00418.96
8.1.150.0070.00018.93
8.1.140.0060.00318.84
8.1.130.0000.00820.19
8.1.120.0000.00717.43
8.1.110.0000.00817.33
8.1.100.0030.00317.53
8.1.90.0080.00017.49
8.1.80.0000.00917.56
8.1.70.0000.00717.45
8.1.60.0000.00817.63
8.1.50.0000.00817.42
8.1.40.0040.00417.58
8.1.30.0000.00817.62
8.1.20.0000.00917.63
8.1.10.0040.00417.49
8.1.00.0040.00417.40
8.0.300.0070.00020.21
8.0.290.0040.00417.00
8.0.280.0000.00818.49
8.0.270.0000.00718.04
8.0.260.0030.00320.03
8.0.250.0030.00416.93
8.0.240.0030.00617.04
8.0.230.0050.00317.08
8.0.220.0070.00016.97
8.0.210.0070.00016.98
8.0.200.0040.00417.05
8.0.190.0040.00417.07
8.0.180.0000.00816.94
8.0.170.0040.00416.99
8.0.160.0040.00416.96
8.0.150.0040.00416.92
8.0.140.0040.00417.00
8.0.130.0000.00713.38
8.0.120.0040.00416.94
8.0.110.0000.00716.93
8.0.100.0070.00016.89
8.0.90.0000.00917.06
8.0.80.0030.01817.04
8.0.70.0040.00417.04
8.0.60.0070.00016.91
8.0.50.0070.00016.86
8.0.30.0140.00317.34
8.0.20.0120.00817.30
8.0.10.0040.00417.23
8.0.00.0070.01117.01
7.4.330.0020.00215.55
7.4.320.0000.00816.68
7.4.300.0040.00416.45
7.4.290.0030.00416.53
7.4.280.0040.00416.63
7.4.270.0100.00016.53
7.4.260.0050.00013.31
7.4.250.0030.00316.40
7.4.240.0000.00716.59
7.4.230.0030.00316.75
7.4.220.0030.00316.73
7.4.210.0090.01116.57
7.4.200.0040.00416.59
7.4.130.0110.00716.60
7.4.120.0070.01016.70
7.4.110.0110.00616.57
7.4.100.0170.00016.53
7.4.90.0110.00716.53
7.4.80.0080.00819.39
7.4.70.0080.00916.64
7.4.60.0160.00616.53
7.4.50.0090.00616.41
7.4.40.0000.01616.40
7.4.30.0040.01116.33
7.4.20.0110.00716.32
7.4.10.0110.00516.58
7.4.00.0040.01316.36
7.3.330.0070.00016.29
7.3.320.0000.00613.36
7.3.310.0030.00316.43
7.3.300.0020.00416.42
7.3.290.0070.01016.38
7.3.280.0030.01616.39
7.3.260.0100.00816.62
7.3.240.0100.00716.58
7.3.230.0080.00816.53
7.3.210.0060.01216.34
7.3.200.0090.00916.36
7.3.190.0060.01216.66
7.3.180.0070.01016.45
7.3.170.0070.01116.59
7.3.160.0140.00316.42
7.3.150.0120.00316.41
7.3.140.0090.00616.39
7.3.130.0070.01016.48
7.3.120.0170.00016.23
7.3.110.0040.01516.58
7.3.100.0080.00816.31
7.3.90.0060.01216.38
7.3.80.0060.01216.39
7.3.70.0100.01316.42
7.3.60.0060.00916.36
7.3.50.0030.01316.23
7.3.40.0130.00316.26
7.3.30.0060.01216.53
7.3.20.0040.01616.43
7.3.10.0190.00616.52
7.3.00.0050.01416.41
7.2.330.0060.01116.66
7.2.320.0090.00916.78
7.2.310.0160.00016.79
7.2.300.0120.00916.56
7.2.290.0030.01416.75
7.2.280.0000.01916.61
7.2.270.0100.01016.51
7.2.260.0040.01316.48
7.2.250.0170.00016.80
7.2.240.0110.00916.46
7.2.230.0080.00816.61
7.2.220.0150.00316.38
7.2.210.0180.00016.70
7.2.200.0080.00816.46
7.2.190.0100.00716.42
7.2.180.0100.01016.61
7.2.170.0090.00916.61
7.2.160.0040.01416.39
7.2.150.0060.01216.58
7.2.140.0180.00016.46
7.2.130.0120.00416.78
7.2.120.0080.01216.57
7.2.110.0070.01216.63
7.2.100.0160.00316.55
7.2.90.0040.01616.54
7.2.80.0110.01116.71
7.2.70.0070.01016.52
7.2.60.0060.01816.71
7.2.50.0140.00616.64
7.2.40.0100.00616.62
7.2.30.0090.01216.74
7.2.20.0070.01116.62
7.2.10.0120.00716.68
7.2.00.0190.00916.54
7.1.330.0100.01315.50
7.1.320.0170.01015.38
7.1.310.0240.00415.56
7.1.300.0170.00915.69
7.1.290.0110.01115.53
7.1.280.0130.00815.71
7.1.270.0180.00315.38
7.1.260.0160.00315.62
7.1.250.0180.00415.46
7.1.240.0160.00615.66
7.1.230.0200.00415.42
7.1.220.0100.01015.34
7.1.210.0130.00715.55
7.1.200.0120.00915.46
7.1.190.0160.00615.65
7.1.180.0220.01215.50
7.1.170.0130.00815.42
7.1.160.0210.00015.31
7.1.150.0100.01715.36
7.1.140.0140.00715.36
7.1.130.0100.01015.30
7.1.120.0150.00315.54
7.1.110.0140.01415.56
7.1.100.0240.00015.49
7.1.90.0330.00715.33
7.1.80.0170.00315.27
7.1.70.0100.01015.38
7.1.60.0110.01115.33
7.1.50.0170.00715.47
7.1.40.0240.00315.29
7.1.30.0110.01115.46
7.1.20.0180.00415.40
7.1.10.0090.01415.41
7.1.00.0160.00615.35
7.0.330.0090.01215.24
7.0.320.0130.01015.20
7.0.310.0160.00315.00
7.0.300.0080.01115.11
7.0.290.0230.00015.07
7.0.280.0200.01314.88
7.0.270.0130.00715.00
7.0.260.0130.01115.16
7.0.250.0160.00815.32
7.0.240.0120.00815.37
7.0.230.0030.01715.23
7.0.220.0080.00815.10
7.0.210.0080.01115.27
7.0.200.0160.00315.14
7.0.190.0080.01314.95
7.0.180.0060.01615.06
7.0.170.0230.00515.01
7.0.160.0190.00815.00
7.0.150.0080.01415.32
7.0.140.0200.00315.14
7.0.130.0160.00815.23
7.0.120.0120.00615.11
7.0.110.0490.01315.09
7.0.100.0110.00814.85
7.0.90.0070.01115.11
7.0.80.0140.00515.03
7.0.70.0100.01415.23
7.0.60.0160.00314.98
7.0.50.0170.00815.11
7.0.40.0030.01715.13
7.0.30.0160.00615.01
7.0.20.0170.00615.23
7.0.10.0190.00815.14
7.0.00.0130.00815.16
5.6.400.0130.01316.01
5.6.390.0090.01215.98
5.6.380.0160.00615.98
5.6.370.0090.01215.80
5.6.360.0070.01415.82
5.6.350.0160.00915.74
5.6.340.0210.00616.04
5.6.330.0140.01115.77
5.6.320.0150.00915.95
5.6.310.0030.01615.89
5.6.300.0150.01115.95
5.6.290.0140.00716.12
5.6.280.0120.01215.63
5.6.270.0200.00315.79
5.6.260.0190.00715.92
5.6.250.0130.01315.91
5.6.240.0170.00716.05
5.6.230.0080.01615.82
5.6.220.0170.00715.70
5.6.210.0110.01115.74
5.6.200.0090.01515.74
5.6.190.0190.00615.90
5.6.180.0220.00416.09
5.6.170.0220.00615.98
5.6.160.0090.01715.93
5.6.150.0100.01615.86
5.6.140.0220.00416.18
5.6.130.0130.01315.86
5.6.120.0160.00916.00
5.6.110.0110.01715.91
5.6.100.0110.01816.09
5.6.90.0100.01715.98
5.6.80.0110.01115.68
5.6.70.0210.00815.96
5.6.60.0180.00615.70
5.6.50.0120.01515.76
5.6.40.0130.00616.11
5.6.30.0110.00915.86
5.6.20.0100.01016.07
5.6.10.0110.00815.90
5.6.00.0030.01615.80
5.5.380.0170.00416.08
5.5.370.0260.00615.98
5.5.360.0170.00615.72
5.5.350.0130.01015.70
5.5.340.0160.00815.93
5.5.330.0120.01215.92
5.5.320.0190.00615.70
5.5.310.0170.01015.74
5.5.300.0180.00915.99
5.5.290.0120.01215.46
5.5.280.0180.00715.80
5.5.270.0100.01615.71
5.5.260.0180.01115.82
5.5.250.0220.00415.79
5.5.240.0070.01915.60
5.5.230.0190.00815.85
5.5.220.0110.01515.67
5.5.210.0140.01115.67
5.5.200.0070.01115.70
5.5.190.0070.01115.80
5.5.180.0090.01015.90
5.5.170.0090.01515.79
5.5.160.0110.00715.84
5.5.150.0120.00615.94
5.5.140.0040.01515.87
5.5.130.0060.01215.87
5.5.120.0090.00915.62
5.5.110.0060.01215.89
5.5.100.0120.00815.88
5.5.90.0040.01515.58
5.5.80.0070.01015.55
5.5.70.0140.00615.73
5.5.60.0100.01015.84
5.5.50.0100.01015.60
5.5.40.0140.00715.70
5.5.30.0030.01615.71
5.5.20.0160.00715.78
5.5.10.0160.00915.50
5.5.00.0040.01615.80
5.4.450.0110.00412.46
5.4.440.0070.01012.41
5.4.430.0110.00712.29
5.4.420.0130.00312.04
5.4.410.0160.00312.32
5.4.400.0180.00312.29
5.4.390.0070.01112.16
5.4.380.0000.01612.28
5.4.370.0120.00612.10
5.4.360.0060.00612.28
5.4.350.0080.00612.34
5.4.340.0090.00312.26
5.4.330.0090.00312.28
5.4.320.0000.01412.33
5.4.310.0090.00312.45
5.4.300.0080.00812.23
5.4.290.0030.01012.25
5.4.280.0060.00612.52
5.4.270.0060.00812.32
5.4.260.0100.00312.56
5.4.250.0060.00912.57
5.4.240.0030.00912.34
5.4.230.0090.00312.13
5.4.220.0100.00312.23
5.4.210.0080.00512.48
5.4.200.0110.00312.29
5.4.190.0030.00912.51
5.4.180.0080.00812.32
5.4.170.0070.00612.26
5.4.160.0100.00312.37
5.4.150.0080.00512.14
5.4.140.0100.00312.23
5.4.130.0090.00412.41
5.4.120.0080.00512.22
5.4.110.0040.01112.31
5.4.100.0090.00512.32
5.4.90.0070.00712.43
5.4.80.0040.01112.29
5.4.70.0090.00312.29
5.4.60.0000.01312.15
5.4.50.0030.00912.08
5.4.40.0070.00712.30
5.4.30.0070.01012.27
5.4.20.0070.00712.11
5.4.10.0070.00712.18
5.4.00.0050.00912.23
5.3.290.0030.01012.85
5.3.280.0060.00612.72
5.3.270.0030.01012.70
5.3.260.0080.00512.76
5.3.250.0110.00313.01
5.3.240.0130.00012.65
5.3.230.0000.01312.77
5.3.220.0030.01112.65
5.3.210.0060.01012.74
5.3.200.0070.00712.71
5.3.190.0040.01112.80
5.3.180.0080.00612.80
5.3.170.0060.00912.84
5.3.160.0130.00413.00
5.3.150.0090.00412.93
5.3.140.0040.01112.91
5.3.130.0100.00312.75
5.3.120.0100.00512.81
5.3.110.0070.00712.77
5.3.100.0100.00312.84
5.3.90.0060.00612.89
5.3.80.0030.01012.98
5.3.70.0000.01412.72
5.3.60.0060.00912.82
5.3.50.0100.00312.74
5.3.40.0110.00412.71
5.3.30.0090.00512.75
5.3.20.0090.00612.68
5.3.10.0030.01312.44
5.3.00.0030.01412.45
5.2.170.0030.01011.86
5.2.160.0040.01111.79
5.2.150.0060.00611.79
5.2.140.0030.00912.00
5.2.130.0030.00911.89
5.2.120.0080.00411.71
5.2.110.0060.00611.73
5.2.100.0130.00311.74
5.2.90.0100.00611.82
5.2.80.0100.00711.71
5.2.70.0090.00611.73
5.2.60.0050.01111.71
5.2.50.0050.01011.71
5.2.40.0000.01611.75
5.2.30.0060.01011.71
5.2.20.0040.01211.71
5.2.10.0030.00911.71
5.2.00.0060.00611.71
5.1.60.0070.00311.71
5.1.50.0030.00811.71
5.1.40.0080.00211.71
5.1.30.0070.00411.71
5.1.20.0080.00311.71
5.1.10.0040.00811.71
5.1.00.0030.00811.71
5.0.50.0050.00511.71
5.0.40.0070.00311.71
5.0.30.0100.00011.71
5.0.20.0090.00011.71
5.0.10.0030.01011.71
5.0.00.0060.00711.71
4.4.90.0040.00411.71
4.4.80.0070.00011.71
4.4.70.0030.00311.71
4.4.60.0000.00611.71
4.4.50.0030.00311.71
4.4.40.0000.00511.71
4.4.30.0030.00311.71
4.4.20.0060.00011.71
4.4.10.0030.00311.71
4.4.00.0050.00311.71
4.3.110.0030.00311.71
4.3.100.0060.00011.71
4.3.90.0040.00411.71
4.3.80.0040.00411.71
4.3.70.0000.00711.71
4.3.60.0040.00411.71
4.3.50.0000.00611.71
4.3.40.0000.00511.71
4.3.30.0000.00611.71
4.3.20.0000.00511.71
4.3.10.0000.00611.71
4.3.00.0030.00311.71

preferences:
70.81 ms | 401 KiB | 5 Q