3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_primes7($n) { if ($n < 2) return array(); if ($n == 2) return array(2); $s = array(); for($i = 3; $i <= $n; $i += 2) $s[] = $i; $mroot = sqrt($n); $half = count($s); $i = 0; $m = 3; while ($m <= $mroot) { if ($s[$i]) { $j = (int)(($m*$m - 3) / 2); $s[$j] = 0; while ($j < $half) { $s[$j] = 0; $j += $m; } } $i = $i + 1; $m = 2*$i + 3; } $res = array(2); foreach ($s as $v) { if ($v) { $res[] = $v; } } return $res; } $res = array(); for ($i = 1; $i <= 10; ++$i) { $res = get_primes7(50000); print "Found ".count($res)." prime numbers.\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)
8.3.40.0070.02419.35
8.3.30.0070.02119.66
8.3.20.0080.00820.84
8.3.10.0060.01020.51
8.3.00.0030.01319.38
8.2.170.0100.01922.96
8.2.160.0100.01920.79
8.2.150.0040.01124.18
8.2.140.0100.00724.66
8.2.130.0030.01226.16
8.2.120.0090.00620.97
8.2.110.0070.02119.95
8.2.100.0060.01618.47
8.2.90.0030.01518.41
8.2.80.0030.01518.13
8.2.70.0040.01518.09
8.2.60.0040.01518.55
8.2.50.0000.02018.13
8.2.40.0060.01218.66
8.2.30.0030.01419.95
8.2.20.0060.01218.30
8.2.10.0060.01218.82
8.2.00.0060.01218.43
8.1.270.0030.01425.71
8.1.260.0100.00626.35
8.1.250.0030.01328.09
8.1.240.0030.02024.71
8.1.230.0100.01322.22
8.1.220.0030.02018.89
8.1.210.0030.01620.20
8.1.200.0090.02018.48
8.1.190.0040.01518.48
8.1.180.0030.01718.48
8.1.170.0100.01019.78
8.1.160.0060.01223.25
8.1.150.0040.01520.13
8.1.140.0040.01518.73
8.1.130.0040.01519.09
8.1.120.0100.01018.58
8.1.110.0030.01518.48
8.1.100.0000.01918.57
8.1.90.0030.01718.53
8.1.80.0150.00418.55
8.1.70.0100.01018.50
8.1.60.0070.02018.71
8.1.50.0040.02118.57
8.1.40.0030.01918.54
8.1.30.0030.02018.73
8.1.20.0030.01918.61
8.1.10.0030.02018.73
8.1.00.0030.02018.54
8.0.300.0030.01621.15
8.0.290.0030.01617.88
8.0.280.0040.01519.57
8.0.270.0070.01118.27
8.0.260.0040.01518.34
8.0.250.0070.01118.02
8.0.240.0030.01617.94
8.0.230.0000.01917.91
8.0.220.0070.01117.90
8.0.210.0120.01217.83
8.0.200.0030.01918.09
8.0.190.0100.01618.01
8.0.180.0000.02317.96
8.0.170.0070.01518.02
8.0.160.0060.01617.84
8.0.150.0000.02217.80
8.0.140.0040.01817.81
8.0.130.0000.02114.40
8.0.120.0030.02017.82
8.0.110.0070.01618.05
8.0.100.0000.02217.86
8.0.90.0040.01817.97
8.0.80.0060.03617.95
8.0.70.0070.01817.86
8.0.60.0000.02517.89
8.0.50.0060.01617.83
8.0.30.0070.03117.95
8.0.20.0180.02818.09
8.0.10.0030.02018.08
8.0.00.0130.03317.73
7.4.330.0000.01616.96
7.4.320.0070.01017.63
7.4.300.0040.01417.59
7.4.290.0070.01417.65
7.4.280.0100.01717.68
7.4.270.0060.01617.69
7.4.260.0000.02517.46
7.4.250.0000.02317.69
7.4.240.0050.01717.57
7.4.230.0030.01917.58
7.4.220.0090.02917.65
7.4.210.0130.02017.59
7.4.200.0000.02317.38
7.4.160.0190.01917.46
7.4.150.0090.02817.54
7.4.140.0080.03117.86
7.4.130.0130.02617.60
7.4.120.0080.03117.63
7.4.110.0070.03417.51
7.4.100.0090.03117.57
7.4.90.0160.01917.42
7.4.80.0060.03719.39
7.4.70.0160.02517.70
7.4.60.0160.01917.48
7.4.50.0060.02317.78
7.4.40.0080.02917.55
7.4.30.0160.01917.58
7.4.00.0040.03416.12
7.3.330.0000.02114.44
7.3.320.0000.02014.43
7.3.310.0040.01817.48
7.3.300.0030.01817.48
7.3.290.0100.02417.40
7.3.280.0070.03417.40
7.3.270.0040.03317.68
7.3.260.0130.02417.49
7.3.250.0130.04417.56
7.3.240.0120.02517.42
7.3.230.0440.02217.79
7.3.210.0070.03117.58
7.3.200.0130.02619.39
7.3.190.0130.02317.51
7.3.180.0130.02317.39
7.3.170.0080.03117.52
7.3.160.0160.03617.62
7.3.120.0090.03415.84
7.3.110.0070.03415.68
7.3.100.0050.03215.81
7.3.90.0050.02715.87
7.3.80.0100.02416.01
7.3.70.0090.02215.92
7.3.60.0050.02415.81
7.3.50.0050.02116.02
7.3.40.0070.02215.84
7.3.30.0070.02915.74
7.3.20.0030.02818.60
7.3.10.0080.02318.44
7.3.00.0050.02418.62
7.2.330.0140.02817.63
7.2.320.0150.02817.56
7.2.310.0090.03217.89
7.2.300.0030.03817.89
7.2.290.0170.02717.66
7.2.250.0000.04116.20
7.2.240.0100.03816.13
7.2.230.0070.03115.92
7.2.220.0030.03116.24
7.2.210.0030.03216.19
7.2.200.0080.02416.22
7.2.190.0070.02616.18
7.2.180.0050.02816.06
7.2.170.0080.02516.05
7.2.130.0130.02318.30
7.2.120.0070.02318.57
7.2.110.0070.02718.81
7.2.100.0070.02818.64
7.2.90.0060.02218.53
7.2.80.0100.02418.85
7.2.70.0100.02218.49
7.2.60.0080.02718.70
7.2.50.0100.02118.95
7.2.40.0090.02218.93
7.2.30.0070.02718.82
7.2.20.0070.02418.91
7.2.10.0000.02919.14
7.2.00.0050.03020.09
7.1.330.0070.03917.76
7.1.320.0100.03317.86
7.1.310.0100.03717.76
7.1.300.0050.03717.91
7.1.290.0100.03617.86
7.1.280.0000.04417.71
7.1.270.0030.03817.73
7.1.260.0080.03617.85
7.1.250.0030.04017.58
7.1.200.0000.03217.59
7.1.100.0030.02720.00
7.1.70.0070.01719.10
7.1.60.0200.02019.61
7.1.50.0160.04618.80
7.1.00.0070.10024.26
7.0.200.0950.02416.18
7.0.140.0100.09324.18
7.0.60.0070.06021.02
7.0.50.0030.06018.92
7.0.40.0070.09720.27
7.0.30.0200.06320.11
7.0.20.0370.09320.23
7.0.10.0130.09020.09
7.0.00.0100.06320.15
5.6.280.0130.16326.18
5.6.210.0170.18325.53
5.6.200.0100.17323.31
5.6.190.0100.12025.45
5.6.180.0230.17725.54
5.6.170.0430.14025.48
5.6.160.0130.12325.50
5.6.150.0300.16023.19
5.6.140.0030.17723.21
5.6.130.0200.17023.23
5.6.120.0070.17726.07
5.6.110.0130.16725.98
5.6.100.0170.17326.06
5.6.90.0130.17326.21
5.6.80.0030.15325.55
5.6.70.4500.12325.45
5.5.350.0270.16725.47
5.5.340.0200.16323.12
5.5.330.0030.11725.27
5.5.320.0270.11025.20
5.5.310.0130.13325.22
5.5.300.0100.14723.00
5.5.290.0100.13723.07
5.5.280.0070.18325.84
5.5.270.0070.18026.04
5.5.260.0530.13325.85
5.5.250.0000.11725.62
5.5.240.0400.13025.27
5.4.450.0530.19024.43
5.4.440.0800.18324.40
5.4.430.0100.16324.50
5.4.420.0670.22024.50
5.4.410.0900.20024.36
5.4.400.0230.18324.18
5.4.390.0130.15723.98
5.4.380.0330.21323.82
5.4.370.0270.18723.60
5.4.360.0270.18323.66
5.4.350.0530.22023.86
5.4.340.0400.19723.65
5.4.320.0090.13517.60
5.4.310.0110.12117.59
5.4.300.0100.12817.59
5.4.290.0070.13617.59
5.4.280.0090.12517.50
5.4.270.0050.14117.49
5.4.260.0080.12317.49
5.4.250.0080.12717.49
5.4.240.0130.13117.49
5.4.230.0070.15117.48
5.4.220.0110.13417.48
5.4.210.0140.16117.48
5.4.200.0100.13917.48
5.4.190.0100.15717.48
5.4.180.0080.13617.48
5.4.170.0130.12817.49
5.4.160.0110.12617.48
5.4.150.0040.12717.48
5.4.140.0100.13517.16
5.4.130.0120.13217.15
5.4.120.0070.12417.11
5.4.110.0090.12617.10
5.4.100.0090.12217.10
5.4.90.0090.13017.10
5.4.80.0100.13617.11
5.4.70.0060.13517.10
5.4.60.0110.11617.10
5.4.50.0100.12317.10
5.4.40.0130.13017.09
5.4.30.0070.14817.09
5.4.20.0070.12017.08
5.4.10.0070.12617.08
5.4.00.0130.13116.58
5.3.290.0120.13617.59
5.3.280.0090.13717.52
5.3.270.0110.19817.53
5.3.260.0080.13817.53
5.3.250.0150.14517.54
5.3.240.0140.13617.53
5.3.230.0110.13617.52
5.3.220.0160.14617.49
5.3.210.0050.14017.49
5.3.200.0110.12417.49
5.3.190.0160.12917.49
5.3.180.0110.14117.49
5.3.170.0070.14217.49
5.3.160.0120.14017.49
5.3.150.0130.13417.49
5.3.140.0110.12917.48
5.3.130.0060.16017.48
5.3.120.0070.19717.47
5.3.110.0090.16617.47
5.3.100.0100.17416.96
5.3.90.0090.15017.05
5.3.80.0090.16116.94
5.3.70.0090.18016.93
5.3.60.0180.20316.92
5.3.50.0140.23816.87
5.3.40.0080.18116.87
5.3.30.0100.17416.83
5.3.20.0110.13716.61
5.3.10.0120.14216.57
5.3.00.0080.19416.55
5.2.170.0080.16713.83
5.2.160.0020.16313.83
5.2.150.0060.13913.83
5.2.140.0060.16913.83
5.2.130.0050.14513.79
5.2.120.0060.14713.79
5.2.110.0070.16713.79
5.2.100.0100.14513.79
5.2.90.0100.13513.79
5.2.80.0020.16413.78
5.2.70.0080.16013.78
5.2.60.0060.15813.73
5.2.50.0050.16613.69
5.2.40.0070.17213.66
5.2.30.0040.17213.64
5.2.20.0070.14513.63
5.2.10.0070.12913.53
5.2.00.0141.98513.43
5.1.60.0110.19014.18
5.1.50.0070.17214.18
5.1.40.0060.15414.16
5.1.30.0030.16614.51
5.1.20.0100.15814.53
5.1.10.0070.17014.20
5.1.00.0080.17514.25
5.0.50.0050.40412.74
5.0.40.0060.35812.60
5.0.30.0050.34212.41
5.0.20.0040.34412.38
5.0.10.0040.35612.35
5.0.00.0090.35912.35
4.4.90.0080.25110.89
4.4.80.0040.26410.88
4.4.70.0080.26110.87
4.4.60.0070.27310.88
4.4.50.0100.26010.89
4.4.40.0090.26910.88
4.4.30.0070.26010.88
4.4.20.0050.26310.94
4.4.10.0040.26110.95
4.4.00.0050.28110.91
4.3.110.0060.26310.82
4.3.100.0060.26510.86
4.3.90.0060.34210.65
4.3.80.0040.35210.64
4.3.70.0050.34510.64
4.3.60.0070.35910.64
4.3.50.0110.34610.64
4.3.40.0030.33710.60
4.3.30.0040.3699.41
4.3.20.0080.4289.39
4.3.10.0100.3679.34
4.3.00.0070.27018.16

preferences:
39.95 ms | 400 KiB | 5 Q