3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyMath { /** * @throws Exception */ public function calculateMedian(array $array): int|float { if (!$array) { throw new LengthException('Cannot calculate median because Argument #1 ($array) is empty'); } sort($array); $middleIndex = count($array) / 2; if (is_float($middleIndex)) { return $array[(int) $middleIndex]; } return ($array[$middleIndex] + $array[$middleIndex - 1]) / 2; } } $math = new MyMath; var_export($math->calculateMedian([1, 2, 3, 4, 5]));

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.5.00.0130.00720.11
8.4.150.0020.00014.05
8.4.140.0130.00817.52
8.4.130.0130.00718.02
8.4.120.0130.00720.57
8.4.110.0110.00818.89
8.4.100.0150.00517.82
8.4.90.0080.01118.10
8.4.80.0120.00617.80
8.4.70.0110.00817.93
8.4.60.0130.00624.46
8.4.50.0360.00917.90
8.4.40.0230.01118.25
8.4.30.0260.00817.98
8.4.20.0190.00718.26
8.4.10.0250.00719.01
8.3.280.0100.01018.37
8.3.270.0120.00816.37
8.3.260.0110.00816.63
8.3.250.0100.00818.99
8.3.240.0100.00819.05
8.3.230.0100.00816.42
8.3.220.0080.01017.35
8.3.210.0090.01016.70
8.3.200.0100.00918.90
8.3.190.0250.00417.38
8.3.180.0240.00717.20
8.3.170.0220.00917.79
8.3.160.0280.00617.06
8.3.150.0250.00716.49
8.3.140.0280.00616.37
8.3.130.0160.00817.11
8.3.120.0170.00717.36
8.3.110.0190.00917.90
8.3.100.0200.00616.26
8.3.90.0220.00819.92
8.3.80.0220.00416.46
8.3.70.0190.01016.38
8.3.60.0240.00816.34
8.3.50.0250.00617.60
8.3.40.0190.00717.73
8.3.30.0200.00717.90
8.3.20.0210.00519.63
8.3.10.0200.00519.80
8.3.00.0140.00520.29
8.2.290.0020.00620.35
8.2.280.0180.00817.10
8.2.270.0230.00316.84
8.2.260.0200.00617.48
8.2.250.0180.00616.59
8.2.240.0180.00516.54
8.2.230.0180.00818.53
8.2.220.0150.00618.89
8.2.210.0170.00519.72
8.2.200.0170.00516.54
8.2.190.0220.00517.15
8.2.180.0170.00719.63
8.2.170.0230.00419.25
8.2.160.0180.00719.31
8.2.150.0220.00420.17
8.2.140.0230.00619.78
8.2.130.0210.00720.35
8.2.120.0150.00720.47
8.2.110.0210.00518.39
8.2.100.0250.00717.73
8.2.90.0200.00717.64
8.2.80.0180.00517.70
8.2.70.0210.00617.45
8.2.60.0210.00817.64
8.2.50.0200.00417.71
8.2.40.0240.00518.40
8.2.30.0230.00417.60
8.2.20.0190.00618.45
8.2.10.0280.00717.63
8.2.00.0170.00518.03
8.1.330.0110.00721.68
8.1.320.0180.00916.04
8.1.310.0170.00516.85
8.1.300.0180.00616.72
8.1.290.0180.00521.07
8.1.280.0180.00819.42
8.1.270.0180.00519.56
8.1.260.0210.00520.29
8.1.250.0150.00821.00
8.1.240.0140.00918.87
8.1.230.0210.00819.61
8.1.220.0210.00517.43
8.1.210.0220.00717.75
8.1.200.0190.00817.37
8.1.190.0210.00517.24
8.1.180.0180.00717.55
8.1.170.0180.00817.69
8.1.160.0200.00717.85
8.1.150.0220.00617.70
8.1.140.0200.00717.22
8.1.130.0170.00917.88
8.1.120.0190.00517.69
8.1.110.0110.00817.65
8.1.100.0140.00517.55
8.1.90.0150.00517.56
8.1.80.0170.00517.56
8.1.70.0150.00417.60
8.1.60.0180.00617.67
8.1.50.0170.00417.63
8.1.40.0160.00617.73
8.1.30.0210.00717.71
8.1.20.0210.00617.75
8.1.10.0230.00417.67
8.1.00.0190.00617.64
8.0.300.0170.00817.62
8.0.290.0260.00616.56
8.0.280.0180.00917.18
8.0.270.0190.00816.95
8.0.260.0210.00617.19
8.0.250.0190.00517.15
8.0.240.0180.00717.07
8.0.230.0170.00717.10
8.0.220.0160.00616.95
8.0.210.0150.00716.94
8.0.200.0160.00617.01
8.0.190.0150.00717.06
8.0.180.0140.00516.93
8.0.170.0120.00816.94
8.0.160.0120.00517.55
8.0.150.0190.00516.96
8.0.140.0140.00816.86
8.0.130.0160.00616.90
8.0.120.0180.00517.03
8.0.110.0180.00516.91
8.0.100.0170.00616.95
8.0.90.0160.00716.97
8.0.80.0170.00616.95
8.0.70.0220.00616.83
8.0.60.0160.00716.91
8.0.50.0180.00416.94
8.0.30.0170.00716.88
8.0.20.0170.00617.05
8.0.10.0160.00517.05
7.4.330.0170.00515.53
7.4.320.0140.00416.62
7.4.300.0120.00716.57
7.4.290.0160.00516.43
7.4.280.0160.00516.53
7.4.270.0140.00416.46
7.4.260.0150.00516.49
7.4.250.0130.00916.47
7.4.240.0190.00516.51
7.4.230.0130.00716.79
7.4.220.0160.00516.47
7.4.210.0140.00816.48
7.4.200.0160.00516.46
7.4.190.0150.00516.50
7.4.180.0190.00316.53
7.4.160.0170.00616.48
7.4.150.0160.00616.48
7.4.140.0180.00316.37
7.4.130.0200.00316.42
7.4.120.0170.00616.23
7.4.110.0190.00416.33
7.4.100.0160.00616.57
7.4.90.0160.00716.34
7.4.80.0160.00616.27
7.4.70.0170.00416.36
7.4.60.0170.00516.35
7.4.50.0170.00416.27
7.4.40.0140.00816.25
7.4.30.0160.00516.41
7.4.20.0140.00416.30
7.4.10.0130.00516.35
7.4.00.0170.00616.39

preferences:
30.45 ms | 403 KiB | 5 Q