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 = range(3, $n, 2); $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(10000); 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.70.0150.00916.63
8.3.60.0110.00716.63
8.3.50.0220.01122.95
8.3.40.0100.00718.85
8.3.30.0100.00619.19
8.3.20.0000.00920.30
8.3.10.0060.00320.52
8.3.00.0090.00019.33
8.2.180.0120.00816.50
8.2.170.0160.00322.96
8.2.160.0110.00720.51
8.2.150.0090.00024.18
8.2.140.0060.00324.66
8.2.130.0000.00926.16
8.2.120.0060.00321.16
8.2.110.0070.00321.98
8.2.100.0080.00619.45
8.2.90.0060.00319.29
8.2.80.0050.00517.97
8.2.70.0030.00617.88
8.2.60.0000.01018.05
8.2.50.0000.01018.07
8.2.40.0090.00018.19
8.2.30.0000.00919.67
8.2.20.0040.00417.78
8.2.10.0000.00918.36
8.2.00.0030.00617.75
8.1.280.0100.00725.92
8.1.270.0040.00424.02
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0100.01319.26
8.1.230.0090.00319.34
8.1.220.0000.01018.04
8.1.210.0110.00018.77
8.1.200.0000.01417.48
8.1.190.0060.00317.47
8.1.180.0030.00718.10
8.1.170.0000.00918.75
8.1.160.0050.00522.16
8.1.150.0030.00619.14
8.1.140.0060.00317.71
8.1.130.0000.00818.06
8.1.120.0060.00317.70
8.1.110.0030.00717.74
8.1.100.0000.00917.73
8.1.90.0030.00617.68
8.1.80.0060.00317.68
8.1.70.0040.00417.71
8.1.60.0030.00917.86
8.1.50.0040.00817.80
8.1.40.0070.00317.73
8.1.30.0030.00917.84
8.1.20.0110.00017.79
8.1.10.0040.00717.78
8.1.00.0100.00017.73
8.0.300.0070.00318.77
8.0.290.0000.00917.00
8.0.280.0000.00918.69
8.0.270.0040.00717.05
8.0.260.0000.00917.56
8.0.250.0050.00317.15
8.0.240.0030.00717.22
8.0.230.0060.00317.09
8.0.220.0030.00617.14
8.0.210.0120.00017.13
8.0.200.0090.00017.09
8.0.190.0000.01017.16
8.0.180.0060.00317.08
8.0.170.0030.00617.09
8.0.160.0030.00617.16
8.0.150.0000.00917.00
8.0.140.0000.01017.11
8.0.130.0060.00313.53
8.0.120.0000.01017.10
8.0.110.0080.00317.08
8.0.100.0030.00616.91
8.0.90.0030.00616.96
8.0.80.0120.00917.07
8.0.70.0040.00717.04
8.0.60.0030.00717.07
8.0.50.0060.00316.99
8.0.30.0110.01017.29
8.0.20.0160.00617.40
8.0.10.0030.00617.19
8.0.00.0070.01716.98
7.4.330.0040.00415.16
7.4.320.0000.00816.65
7.4.300.0040.00416.84
7.4.290.0000.00916.82
7.4.280.0050.00916.83
7.4.270.0040.00416.84
7.4.260.0030.00616.80
7.4.250.0030.00616.70
7.4.240.0010.00716.80
7.4.230.0000.00916.90
7.4.220.0080.01116.75
7.4.210.0100.00716.79
7.4.200.0100.00016.95
7.4.160.0030.01516.62
7.4.150.0110.01117.40
7.4.140.0100.01517.86
7.4.130.0120.00916.78
7.4.120.0080.01416.70
7.4.110.0070.01416.81
7.4.100.0070.01316.71
7.4.90.0130.00716.68
7.4.80.0070.01719.39
7.4.70.0130.01016.89
7.4.60.0100.01016.78
7.4.50.0000.01116.79
7.4.40.0090.01116.94
7.4.30.0060.01316.77
7.4.00.0000.01814.89
7.3.330.0000.00813.57
7.3.320.0030.00313.41
7.3.310.0060.00316.51
7.3.300.0000.00916.47
7.3.290.0080.00816.62
7.3.280.0080.01216.59
7.3.270.0080.01217.40
7.3.260.0110.00816.75
7.3.250.0100.01016.84
7.3.240.0120.00916.90
7.3.230.0080.01316.63
7.3.210.0140.01116.63
7.3.200.0170.00319.39
7.3.190.0120.00616.75
7.3.180.0130.01016.81
7.3.170.0100.01316.69
7.3.160.0070.01316.60
7.2.330.0150.00616.86
7.2.320.0000.02016.84
7.2.310.0030.01816.84
7.2.300.0120.00917.17
7.2.290.0070.01416.89
7.2.110.0160.00316.64
7.2.100.1630.01316.81
7.2.90.0120.00616.46
7.2.80.0160.00416.64
7.2.70.0490.01017.03
7.2.60.0200.00716.93
7.2.50.0110.01417.07
7.2.40.0170.00616.74
7.2.30.0160.00417.15
7.2.20.0170.00316.95
7.2.10.0290.00417.16
7.2.00.0090.01018.36
7.1.230.0100.00615.61
7.1.220.0940.00715.52
7.1.210.0100.00915.89
7.1.200.0030.01615.87
7.1.190.0350.00715.79
7.1.180.0120.00815.85
7.1.170.0140.00615.70
7.1.160.0130.00915.95
7.1.150.0090.00615.72
7.1.140.0060.01315.81
7.1.130.0190.00815.72
7.1.120.0080.01315.94
7.1.110.0120.00615.82
7.1.100.0070.01216.94
7.1.90.0130.00715.98
7.1.80.0180.00315.82
7.1.70.0100.00616.59
7.1.60.0120.01217.79
7.1.50.0070.01816.52
7.1.40.0100.01015.88
7.1.30.0130.00915.96
7.1.20.0110.01115.85
7.1.10.0150.00415.77
7.1.00.0070.04418.98
7.0.310.0100.00815.47
7.0.300.0090.01615.21
7.0.290.0190.01015.34
7.0.280.0300.00415.40
7.0.270.0110.00715.47
7.0.260.0070.00715.11
7.0.250.0130.01615.58
7.0.240.0060.00915.48
7.0.230.0060.00915.36
7.0.220.0040.01215.31
7.0.210.0060.01115.61
7.0.200.0230.00815.27
7.0.190.0590.01015.39
7.0.180.0080.01215.53
7.0.170.0060.00915.33
7.0.160.0380.01015.27
7.0.150.0090.00915.45
7.0.140.0080.04118.65
7.0.130.0240.00915.27
7.0.120.0140.00415.23
7.0.110.0140.00715.53
7.0.100.0120.00515.13
7.0.90.0120.00815.18
7.0.80.0110.00815.55
7.0.70.0120.00815.22
7.0.60.0080.04517.76
7.0.50.0060.05516.82
7.0.40.0070.02616.79
7.0.30.0180.03316.91
7.0.20.0170.04716.83
7.0.10.0070.04916.67
7.0.00.0080.02416.82
5.6.380.0100.02315.67
5.6.370.0190.01315.21
5.6.360.0100.02115.30
5.6.350.0110.02615.84
5.6.340.0070.02815.91
5.6.330.0120.02214.89
5.6.320.0110.02515.62
5.6.310.0150.02215.32
5.6.300.0130.01915.63
5.6.290.0090.01915.34
5.6.280.0110.05418.88
5.6.270.0130.02315.47
5.6.260.0140.01715.49
5.6.250.0110.02215.66
5.6.240.0090.01815.45
5.6.230.0120.02115.43
5.6.220.0160.01615.45
5.6.210.0070.05818.69
5.6.200.0090.03617.31
5.6.190.0110.05818.45
5.6.180.2020.03718.44
5.6.170.0140.04418.47
5.6.160.0100.05418.36
5.6.150.0050.05917.26
5.6.140.0090.04417.33
5.6.130.0130.06017.38
5.6.120.0070.03418.88
5.6.110.0100.05518.76
5.6.100.0130.04918.78
5.6.90.0120.06518.72
5.6.80.0090.03418.39
5.6.70.0090.02415.48
5.6.60.0070.02715.37
5.6.50.0130.01915.30
5.6.40.0110.01815.30
5.6.30.0100.02315.23
5.6.20.0100.02215.54
5.6.10.0100.01715.28
5.6.00.0160.01615.46
5.5.380.0120.02012.79
5.5.370.0150.01812.79
5.5.360.0130.01712.79
5.5.350.0190.06317.16
5.5.340.0130.05915.86
5.5.330.0060.03716.99
5.5.320.0150.03717.04
5.5.310.0190.03916.99
5.5.300.0050.05015.86
5.5.290.0070.03715.91
5.5.280.0050.03817.29
5.5.270.0090.03917.29
5.5.260.0040.03717.29
5.5.250.0120.06217.20
5.5.240.0060.05817.03
5.5.230.0090.02212.79
5.5.220.0040.02612.79
5.5.210.0160.01612.79
5.5.200.0090.01612.79
5.5.190.0120.01812.79
5.5.180.0070.02312.79
5.5.170.0100.01815.19
5.5.160.0060.02212.79
5.5.150.0110.01812.79
5.5.140.0040.02212.79
5.5.130.0060.02012.79
5.5.120.0000.02512.79
5.5.110.0070.02012.79
5.5.100.0100.01612.79
5.5.90.0000.02512.79
5.5.80.0100.02112.79
5.5.70.0090.01812.79
5.5.60.0070.02412.79
5.5.50.0040.02312.79
5.5.40.0130.02312.79
5.5.30.0150.01512.79
5.5.20.0070.02112.79
5.5.10.0100.02012.79
5.5.00.0070.02312.79
5.4.450.0240.03216.59
5.4.440.0250.03316.64
5.4.430.0270.04316.49
5.4.420.0440.04416.50
5.4.410.0550.05916.55
5.4.400.0380.04716.47
5.4.390.0450.05016.46
5.4.380.0250.04216.27
5.4.370.0160.04216.28
5.4.360.0210.04116.21
5.4.350.0270.05216.29
5.4.340.0180.04416.20
5.4.330.0120.01812.79
5.4.320.0090.03413.17
5.4.310.0060.03513.17
5.4.300.0090.03213.17
5.4.290.0140.03013.17
5.4.280.0060.03313.12
5.4.270.0070.03713.12
5.4.260.0060.03713.11
5.4.250.0080.03613.11
5.4.240.0070.03413.12
5.4.230.0060.03713.11
5.4.220.0090.03213.11
5.4.210.0030.03613.11
5.4.200.0040.03813.11
5.4.190.0060.03813.11
5.4.180.0070.03413.11
5.4.170.0080.03413.11
5.4.160.0120.03013.11
5.4.150.0090.03213.11
5.4.140.0080.03512.95
5.4.130.0120.03012.94
5.4.120.0100.03212.92
5.4.110.0050.03512.92
5.4.100.0100.02912.92
5.4.90.0080.03612.92
5.4.80.0110.03312.92
5.4.70.0040.04012.92
5.4.60.0070.03412.92
5.4.50.0060.03712.92
5.4.40.0080.03512.91
5.4.30.0060.03712.91
5.4.20.0050.03512.91
5.4.10.0080.03312.91
5.4.00.0140.02912.66
5.3.290.0080.03513.31
5.3.280.0080.03513.28
5.3.270.0080.03613.28
5.3.260.0070.03913.29
5.3.250.0070.03913.28
5.3.240.0080.04013.28
5.3.230.0100.03313.28
5.3.220.0050.03913.26
5.3.210.0100.03313.26
5.3.200.0040.03813.26
5.3.190.0050.03813.26
5.3.180.0060.03713.26
5.3.170.0060.03713.26
5.3.160.0080.03513.26
5.3.150.0060.03613.26
5.3.140.0070.03713.26
5.3.130.0090.03713.26
5.3.120.0070.03613.25
5.3.110.0050.03813.25
5.3.100.0090.03613.00
5.3.90.0060.03812.99
5.3.80.0080.03512.99
5.3.70.0040.03812.99
5.3.60.0080.03412.98
5.3.50.0090.03412.95
5.3.40.0080.03412.95
5.3.30.0060.03612.93
5.3.20.0090.03112.82
5.3.10.0090.03612.80
5.3.00.0070.03612.83
5.2.170.0080.03611.55
5.2.160.0080.04111.56
5.2.150.0060.03411.56
5.2.140.0080.03311.56
5.2.130.0060.03311.54
5.2.120.0080.03111.54
5.2.110.0050.03911.54
5.2.100.0050.03411.54
5.2.90.0050.03811.54
5.2.80.0070.03511.53
5.2.70.0080.03211.53
5.2.60.0050.03811.51
5.2.50.0070.03511.49
5.2.40.0050.03911.48
5.2.30.0040.03611.40
5.2.20.0050.03511.40
5.2.10.0080.03211.35
5.2.00.0050.09111.17
5.1.60.0070.03311.09
5.1.50.0040.03411.08
5.1.40.0040.03811.07
5.1.30.0030.03711.25
5.1.20.0040.03911.26
5.1.10.0070.03311.12
5.1.00.0060.03611.12
5.0.50.0070.05310.36
5.0.40.0060.05510.29
5.0.30.0050.05910.20
5.0.20.0030.05610.19
5.0.10.0050.05410.17
5.0.00.0070.05910.17
4.4.90.0040.0088.78
4.4.80.0010.0128.77
4.4.70.0030.0128.77
4.4.60.0030.0108.77
4.4.50.0060.0098.78
4.4.40.0060.0188.75
4.4.30.0020.0128.77
4.4.20.0030.0138.82
4.4.10.0030.0108.82
4.4.00.0020.0168.77
4.3.110.0040.0088.73
4.3.100.0040.0078.73
4.3.90.0030.0098.71
4.3.80.0020.0158.69
4.3.70.0050.0088.71
4.3.60.0050.0078.71
4.3.50.0010.0118.71
4.3.40.0030.0158.66
4.3.30.0010.0118.05
4.3.20.0010.0138.04
4.3.10.0010.0128.02
4.3.00.0090.00715.47

preferences:
46.72 ms | 401 KiB | 5 Q