3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MY_ORDER', [0 => 2, 1 => 3, 2 => 0, 8 => 1]); $array = [2, 2, 2, 1, 1, 0, 0, 8]; usort($array, function ($a, $b) { static $cache; return ($cache[$a] ??= keyfn($a)) <=> ($cache[$b] ??= keyfn($b)); }); var_export($array); function keyfn($v) { echo "called for $v\n"; return MY_ORDER[$v]; }

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.10.0130.00620.23
8.5.00.0150.01120.02
8.4.160.0120.01223.89
8.4.150.0010.00114.05
8.4.140.0110.00917.96
8.4.130.0050.00417.63
8.4.120.0100.00420.55
8.4.110.0120.00818.76
8.4.100.0110.01017.85
8.4.90.0110.01017.83
8.4.80.0040.00421.44
8.4.70.0110.01018.08
8.4.60.0170.00317.96
8.4.50.0120.00818.77
8.4.40.0160.00320.54
8.4.30.0030.01618.73
8.4.20.0140.00617.73
8.4.10.0030.00623.97
8.3.280.0100.01018.49
8.3.270.0090.01016.66
8.3.260.0090.01016.67
8.3.250.0070.00319.02
8.3.240.0110.00816.69
8.3.230.0110.00816.59
8.3.220.0110.00917.14
8.3.210.0110.00916.55
8.3.200.0070.01316.63
8.3.190.0110.00719.16
8.3.180.0100.00818.72
8.3.170.0150.00318.54
8.3.160.0070.01117.23
8.3.150.0150.00416.62
8.3.140.0120.00618.92
8.3.130.0090.00018.59
8.3.120.0120.00620.59
8.3.110.0060.00320.94
8.3.100.0040.00424.06
8.3.90.0040.00426.77
8.3.80.0000.00918.68
8.3.70.0140.00016.60
8.3.60.0150.00620.48
8.3.50.0140.00718.60
8.3.40.0080.00620.26
8.3.30.0110.00418.73
8.3.20.0040.00424.18
8.3.10.0000.00824.66
8.3.00.0000.00726.16
8.2.290.0090.00920.67
8.2.280.0150.00316.90
8.2.270.0070.01116.75
8.2.260.0160.00318.49
8.2.250.0030.00616.88
8.2.240.0030.00618.96
8.2.230.0060.00622.58
8.2.220.0000.01137.54
8.2.210.0100.00326.77
8.2.200.0080.00016.63
8.2.190.0150.00416.63
8.2.180.0120.00325.92
8.2.170.0090.00618.95
8.2.160.0140.00422.96
8.2.150.0080.00025.66
8.2.140.0050.00224.66
8.2.130.0000.00826.16
8.2.120.0070.00026.16
8.2.110.0060.00619.16
8.2.100.0090.00317.91
8.2.90.0000.00719.38
8.2.80.0030.00519.28
8.2.70.0040.00417.75
8.2.60.0030.00517.91
8.2.50.0050.00318.07
8.2.40.0080.00018.30
8.2.30.0080.00018.18
8.2.20.0040.00419.20
8.2.10.0070.00018.01
8.2.00.0050.00319.41
8.1.330.0130.00616.45
8.1.320.0100.01016.21
8.1.310.0110.00716.32
8.1.300.0150.00418.30
8.1.290.0110.00030.84
8.1.280.0120.00625.92
8.1.270.0040.00424.66
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0080.00022.20
8.1.230.0120.00020.91
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0000.00917.22
8.1.190.0090.00017.36
8.1.180.0030.00518.10
8.1.170.0000.00818.66
8.1.160.0070.00318.99
8.1.150.0000.00818.60
8.1.140.0000.00717.34
8.1.130.0000.00718.77
8.1.120.0000.00717.37
8.1.110.0000.00817.37
8.1.100.0000.00717.41
8.1.90.0110.00517.35
8.1.80.0120.00417.35
8.1.70.0120.00317.39
8.1.60.0140.00417.48
8.1.50.0130.00417.49
8.1.40.0130.00417.39
8.1.30.0100.00817.63
8.1.20.0160.00217.59
8.1.10.0090.00817.59
8.1.00.0140.00317.51
8.0.300.0000.00819.96
8.0.290.0000.00916.75
8.0.280.0080.00018.45
8.0.270.0030.00316.88
8.0.260.0060.00018.52
8.0.250.0020.00516.89
8.0.240.0000.00717.02
8.0.230.0070.00016.98
8.0.220.0150.00016.90
8.0.210.0030.01016.90
8.0.200.0110.00516.84
8.0.190.0150.00016.87
8.0.180.0080.00716.84
8.0.170.0070.00716.94
8.0.160.0130.00116.85
8.0.150.0120.00316.78
8.0.140.0140.00016.83
8.0.130.0070.00716.80
8.0.120.0110.00416.89
8.0.110.0110.00316.83
8.0.100.0050.01016.84
8.0.90.0130.00316.82
8.0.80.0090.00716.79
8.0.70.0100.00516.79
8.0.60.0130.00216.80
8.0.50.0080.00716.79
8.0.30.0120.00216.74
8.0.20.0140.00016.91
8.0.10.0110.00417.01
7.4.330.0030.00315.55
7.4.320.0000.00716.51
7.4.300.0100.00316.60
7.4.290.0040.00716.49
7.4.280.0050.00516.56
7.4.270.0060.00516.52
7.4.260.0090.00516.51
7.4.250.0100.00616.38
7.4.240.0060.01016.51
7.4.230.0100.00516.51
7.4.220.0110.00416.47
7.4.210.0070.00616.44
7.4.200.0100.00316.59
7.4.190.0080.00616.52
7.4.180.0120.00216.68
7.4.160.0120.00216.52
7.4.150.0100.00316.46
7.4.140.0100.00416.40
7.4.130.0110.00316.48
7.4.120.0130.00116.49
7.4.110.0130.00016.33
7.4.100.0080.00516.42
7.4.90.0080.00616.46
7.4.80.0120.00216.39
7.4.70.0110.00216.48
7.4.60.0090.00516.38
7.4.50.0110.00216.42
7.4.40.0090.00416.34
7.4.30.0070.00716.38
7.4.20.0100.00416.45
7.4.10.0110.00216.45
7.4.00.0110.00216.41

preferences:
36.61 ms | 403 KiB | 5 Q