3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SwitchStage{ function __construct( public array $branches = [], public ?int $default = null ) {} function branch(int $case, int $then) { $this->branches[] = (object) ['case' => $case, 'then' => $then]; return $this; } function default(int $default) { $this->default = $default; return $this; } } $x = (new SwitchStage()) ->branch(case: 1, then: 2) ->branch(case: 3, then: 4) ->default(5); var_dump($x); $x = new SwitchStage([ ['case' => 1, 'then' => 2], ['case' => 3, 'then' => 4], ], default: 5); var_dump($x);

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.4.130.0120.01017.39
8.4.120.0110.00922.25
8.4.110.0130.01018.88
8.4.100.0100.00917.64
8.4.90.0100.00717.73
8.4.80.0140.00617.97
8.4.70.0030.00617.83
8.4.60.0080.00719.34
8.4.50.0050.00419.50
8.4.40.0030.01817.61
8.4.30.0080.01118.61
8.4.20.0100.01018.05
8.4.10.0130.00719.60
8.3.260.0110.00816.58
8.3.250.0050.00420.53
8.3.240.0140.00518.29
8.3.230.0150.00616.54
8.3.220.0110.00817.32
8.3.210.0060.00316.60
8.3.200.0120.00816.65
8.3.190.0100.00218.63
8.3.180.0030.00620.77
8.3.170.0070.01118.93
8.3.160.0030.01518.56
8.3.150.0100.01020.63
8.3.140.0040.00420.59
8.3.130.0150.00018.65
8.3.120.0060.00318.88
8.3.110.0040.00420.94
8.3.100.0080.00024.06
8.3.90.0190.00026.77
8.3.80.0030.00618.31
8.3.70.0000.01618.43
8.3.60.0060.00916.38
8.3.50.0030.01216.55
8.3.40.0100.00721.86
8.3.30.0110.00418.50
8.3.20.0080.00024.18
8.3.10.0110.00424.66
8.3.00.0040.00426.16
8.2.290.0090.00920.63
8.2.280.0060.00216.39
8.2.270.0110.00719.08
8.2.260.0060.01316.64
8.2.250.0060.00316.69
8.2.240.0080.00817.07
8.2.230.0000.00822.58
8.2.220.0030.00737.54
8.2.210.0070.00326.77
8.2.200.0090.00016.75
8.2.190.0130.00318.52
8.2.180.0130.00716.63
8.2.170.0100.01019.00
8.2.160.0070.01122.96
8.2.150.0050.00225.66
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0060.00319.36
8.2.110.0130.01022.11
8.2.100.0040.00720.64
8.2.90.0140.01020.64
8.2.80.0080.00320.45
8.2.70.0100.00020.36
8.2.60.0030.00720.32
8.2.50.0070.00420.55
8.2.40.0050.00520.25
8.2.30.0080.00320.49
8.2.20.0110.00020.41
8.2.10.0110.00020.42
8.2.00.0100.00020.56
8.1.330.0140.00616.81
8.1.320.0080.00517.67
8.1.310.0040.00418.71
8.1.300.0120.00617.91
8.1.290.0070.00330.84
8.1.280.0110.00725.92
8.1.270.0070.00024.66
8.1.260.0040.00426.35
8.1.250.0030.00628.09
8.1.240.0040.00720.17
8.1.230.0030.00720.27
8.1.220.0050.00520.41
8.1.210.0000.00921.60
8.1.200.0060.00320.29
8.1.190.0000.01320.13
8.1.180.0000.01119.95
8.1.170.0100.00020.23
8.1.160.0110.00020.21
8.1.150.0030.00720.38
8.1.140.0070.00420.33
8.1.130.0070.00320.27
8.1.120.0070.00320.20
8.1.110.0080.00320.07
8.1.100.0060.00320.41
8.1.90.0040.00820.27
8.1.80.0050.00520.26
8.1.70.0100.00020.38
8.1.60.0040.00720.44
8.1.50.0080.00320.34
8.1.40.0070.00320.41
8.1.30.0090.00320.64
8.1.20.0030.01020.56
8.1.10.0090.00320.35
8.1.00.0070.00320.43
8.0.300.0110.00019.48
8.0.290.0030.00719.61
8.0.280.0030.00719.57
8.0.270.0090.00019.61
8.0.260.0040.00819.64
8.0.250.0070.00319.43
8.0.240.0060.00319.66
8.0.230.0000.00919.55
8.0.220.0050.00519.66
8.0.210.0080.00319.56
8.0.200.0060.00319.55
8.0.190.0040.00419.61
8.0.180.0070.00319.70
8.0.170.0110.00019.57
8.0.160.0030.00619.39
8.0.150.0050.00519.42
8.0.140.0110.00019.53
8.0.130.0060.00619.68
8.0.120.0060.00319.65
8.0.110.0030.00619.60
8.0.100.0100.00019.58
8.0.90.0030.00619.41
8.0.80.0100.00019.57
8.0.70.0030.00619.60
8.0.60.0080.00319.54
8.0.50.0000.01019.57
8.0.30.0070.00319.50
8.0.20.0070.00319.78
8.0.10.0000.01119.95

preferences:
28.34 ms | 403 KiB | 5 Q