3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() {} $nIter = 1000000; $argNums = array(0, 1, 2, 3, 4, 5, 100); $func = 'test'; foreach ($argNums as $argNum) { $args = $argNum == 0 ? [] : array_fill(0, $argNum, null); $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { call_user_func_array($func, $args); } $endTime = microtime(true); echo "cufa with $argNum args took ", $endTime - $startTime, "\n"; $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { switch (count($args)) { case 0: $func(); break; case 1: $func($args[0]); break; case 2: $func($args[0], $args[1]); break; case 3: $func($args[0], $args[1], $args[2]); break; case 4: $func($args[0], $args[1], $args[2], $args[3]); break; case 5: $func($args[0], $args[1], $args[2], $args[3], $args[4]); break; default: call_user_func_array($func, $args); break; } } $endTime = microtime(true); echo "switch with $argNum args took ", $endTime - $startTime, "\n"; }

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)
7.3.10.0101.56616.78
7.3.00.0201.56016.68
7.2.130.0171.54316.87
7.2.120.0171.58016.87
7.2.110.0071.61416.90
7.2.100.0131.57917.02
7.2.90.0131.61016.82
7.2.80.0301.61116.90
7.2.70.0101.55916.95
7.2.60.0031.60416.78
7.2.50.0031.66617.12
7.2.40.0071.59716.68
7.2.30.0101.60917.07
7.2.20.0071.64216.90
7.2.10.0071.55116.93
7.2.00.0071.54118.14
7.1.250.0032.41215.68
7.1.70.0031.70417.19
7.1.60.0031.52019.24
7.1.50.0031.57016.93
7.1.00.0101.79022.45
7.0.200.0101.68816.80
7.0.140.0001.62022.07
7.0.100.0271.47320.10
7.0.90.0131.50020.05
7.0.80.0071.51020.00
7.0.70.0031.70720.00
7.0.60.0101.39719.97
7.0.50.0131.57020.39
7.0.40.0131.55020.13
7.0.30.0101.57020.03
7.0.20.0001.51320.15
7.0.10.0031.49720.09
7.0.00.0171.52720.18
5.6.280.0002.50020.87
5.6.250.0032.49720.73
5.6.240.0072.49320.56
5.6.230.0072.49320.70
5.6.220.0032.49720.63
5.6.210.0072.48020.76
5.6.200.0102.47021.07
5.6.190.0102.49020.95
5.6.180.0032.49721.03
5.6.170.0202.48021.14
5.6.160.0102.49021.02
5.6.150.0032.47721.07
5.6.140.0002.50021.02
5.6.130.0072.49321.03
5.6.120.0002.50021.02
5.6.110.0102.48320.94
5.6.100.0172.48321.11
5.6.90.0032.49720.95
5.6.80.0102.49020.53
5.6.70.0102.49020.52
5.6.60.0072.49320.35
5.6.50.0032.49720.43
5.6.40.0072.49320.45
5.6.30.0132.48720.50
5.6.20.0072.49320.31
5.6.10.0072.49320.50
5.6.00.0032.49720.43
5.5.380.0172.48320.47
5.5.370.2772.22020.41
5.5.360.0232.45020.53
5.5.350.0232.25020.41
5.5.340.0132.48720.87
5.5.330.0132.36320.94
5.5.320.0171.16020.96
5.5.310.0232.38720.81
5.5.300.0002.50020.74
5.5.290.0272.44320.94
5.5.280.0032.49720.81
5.5.270.0202.43720.94
5.5.260.0072.49320.83
5.5.250.0232.43720.77
5.5.240.0072.49320.17
5.5.230.0272.44020.37
5.5.220.0002.50020.28
5.5.210.0102.44320.32
5.5.200.0072.49320.25
5.5.190.0202.42020.28
5.5.180.0072.46320.25
5.5.160.0102.40720.12
5.5.150.0032.11720.22
5.5.140.0201.85020.23
5.5.130.0132.48720.24
5.5.120.0202.04720.33
5.5.110.0032.49720.18
5.5.100.0202.42720.03
5.5.90.0172.45720.18
5.5.80.0102.49020.01
5.5.70.0102.49020.06
5.5.60.0172.48320.16
5.5.50.0132.48720.04
5.5.40.0202.48020.13
5.5.30.0172.43320.12
5.5.20.0132.48720.05
5.5.10.0172.44020.19
5.5.00.0072.49320.03
5.4.450.0102.49019.16
5.4.440.0102.45019.22
5.4.430.0102.43319.18
5.4.420.0102.49019.38
5.4.410.0002.50019.09
5.4.400.0002.47019.05
5.4.390.0172.48318.83
5.4.380.0132.45319.13
5.4.370.0132.48718.80
5.4.360.0132.45719.04
5.4.350.0032.49718.94
5.4.340.0102.42719.07
5.4.320.0072.49319.05
5.4.310.0132.19719.08
5.4.300.0131.91718.93
5.4.290.0202.48019.00
5.4.280.0032.49718.97
5.4.270.0202.24019.04
5.4.260.0202.45319.11
5.4.250.0232.45019.19
5.4.240.0032.49718.97
5.4.230.0102.49018.96
5.4.220.0072.49319.00
5.4.210.0232.43318.91
5.4.200.0102.49019.15
5.4.190.0172.43019.04
5.4.180.0202.44019.05
5.4.170.0102.43019.09
5.4.160.0072.49318.88
5.4.150.0232.45019.02
5.4.140.0202.42016.42
5.4.130.0302.17016.25
5.4.120.0301.97716.57
5.4.110.0301.65016.27
5.4.100.0072.49316.45
5.4.90.0032.49716.28
5.4.80.0271.26716.32
5.4.70.0072.49316.36
5.4.60.0032.49716.39
5.4.50.0271.91316.49
5.4.40.0102.00016.45
5.4.30.0032.49716.31
5.4.20.0072.49316.35
5.4.10.0272.18316.39
5.4.00.0072.49315.86
5.3.290.0000.05714.70
5.3.280.0070.07714.66
5.3.270.0130.05714.66
5.3.260.0000.08014.70
5.3.250.0000.04714.59
5.3.240.0030.03714.59
5.3.230.0170.02014.59
5.3.220.0030.08014.54
5.3.210.0070.07014.54
5.3.200.0070.07314.67
5.3.190.0070.07014.60
5.3.180.0030.07014.67
5.3.170.0100.06014.57
5.3.160.0000.04314.59
5.3.150.0030.06014.52
5.3.140.0100.06314.52
5.3.130.0070.07314.61
5.3.120.0070.05014.65
5.3.110.0070.06714.61
5.3.100.0030.08014.10
5.3.90.0030.04714.08
5.3.80.0070.03714.06
5.3.70.0070.08014.14
5.3.60.0030.07013.94
5.3.50.0130.06313.84
5.3.40.0100.05313.95
5.3.30.0070.06313.96
5.3.20.0070.07713.71
5.3.10.0130.06713.59
5.3.00.0000.08713.57
5.2.170.0170.03311.16
5.2.160.0030.04311.13
5.2.150.0030.06311.15
5.2.140.0030.04011.07
5.2.130.0000.04711.11
5.2.120.0070.05011.16
5.2.110.0000.03711.12
5.2.100.0030.03311.20
5.2.90.0070.03011.00
5.2.80.0070.06311.23
5.2.70.0030.06710.95
5.2.60.0170.04711.09
5.2.50.0130.05311.02
5.2.40.0030.05711.08
5.2.30.0170.02310.98
5.2.20.0030.02710.91
5.2.10.0030.06310.86
5.2.00.0100.04310.64
5.1.60.0000.0509.96
5.1.50.0000.02710.02
5.1.40.0030.0309.86
5.1.30.0030.05010.37
5.1.20.0130.04310.34
5.1.10.0000.0379.92
5.1.00.0070.05310.17
5.0.50.0070.0338.38
5.0.40.0000.0478.50
5.0.30.0000.0408.07
5.0.20.0000.0408.32
5.0.10.0070.0308.01
5.0.00.0000.0678.18
4.4.90.0000.0237.48
4.4.80.0000.0207.48
4.4.70.0030.0237.48
4.4.60.0000.0377.48
4.4.50.0000.0277.48
4.4.40.0000.0307.48
4.4.30.0000.0177.48
4.4.20.0030.0307.48
4.4.10.0000.0407.48
4.4.00.0030.0237.49
4.3.110.0000.0307.50
4.3.100.0030.0377.50
4.3.90.0030.0377.52
4.3.80.0000.0477.53
4.3.70.0000.0377.54
4.3.60.0030.0177.56
4.3.50.0000.0377.57
4.3.40.0070.0237.57
4.3.30.0000.0337.58
4.3.20.0000.0207.58
4.3.10.0000.0337.59
4.3.00.0070.0307.59

preferences:
40.89 ms | 401 KiB | 5 Q