3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); 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.60.0090.00918.27
8.3.50.0110.01122.90
8.3.40.0130.00318.76
8.3.30.0070.01019.21
8.3.20.0090.00020.45
8.3.10.0000.00920.66
8.3.00.0030.00619.38
8.2.180.0100.00718.54
8.2.170.0060.01022.96
8.2.160.0080.01220.56
8.2.150.0030.00624.18
8.2.140.0060.00324.66
8.2.130.0030.00626.16
8.2.120.0000.00821.01
8.2.110.0110.00020.52
8.2.100.0080.00618.03
8.2.90.0000.00919.47
8.2.80.0030.00617.97
8.2.70.0060.00317.75
8.2.60.0030.00618.05
8.2.50.0040.00718.07
8.2.40.0030.00618.22
8.2.30.0030.00619.59
8.2.20.0050.00517.77
8.2.10.0030.00618.26
8.2.00.0000.01017.85
8.1.280.0130.01025.92
8.1.270.0110.00023.81
8.1.260.0030.00626.35
8.1.250.0030.00628.09
8.1.240.0070.00423.81
8.1.230.0090.00321.18
8.1.220.0000.00918.02
8.1.210.0060.00318.77
8.1.200.0060.00617.60
8.1.190.0030.00617.47
8.1.180.0060.00318.10
8.1.170.0100.00318.84
8.1.160.0030.00622.32
8.1.150.0060.00319.07
8.1.140.0070.00317.75
8.1.130.0000.01018.00
8.1.120.0060.00317.70
8.1.110.0000.00917.71
8.1.100.0030.00617.62
8.1.90.0030.00617.77
8.1.80.0040.00417.77
8.1.70.0090.00017.73
8.1.60.0000.01117.78
8.1.50.0000.01117.78
8.1.40.0070.00317.76
8.1.30.0040.00717.82
8.1.20.0040.00717.90
8.1.10.0030.00617.79
8.1.00.0030.00717.82
8.0.300.0030.00618.77
8.0.290.0040.00417.00
8.0.280.0050.00518.66
8.0.270.0030.00617.63
8.0.260.0030.00617.44
8.0.250.0000.00817.29
8.0.240.0030.00717.26
8.0.230.0030.00617.13
8.0.220.0050.00517.13
8.0.210.0030.00917.10
8.0.200.0060.00317.25
8.0.190.0070.00317.23
8.0.180.0030.00717.15
8.0.170.0030.00617.04
8.0.160.0000.00917.23
8.0.150.0060.00717.09
8.0.140.0060.00317.01
8.0.130.0000.00813.46
8.0.120.0030.00717.15
8.0.110.0070.00317.05
8.0.100.0030.00617.04
8.0.90.0000.00916.98
8.0.80.0190.00317.20
8.0.70.0030.00716.95
8.0.60.0030.00617.04
8.0.50.0060.00317.03
8.0.30.0080.01417.32
8.0.20.0090.01617.52
8.0.10.0060.00317.30
8.0.00.0050.01616.96
7.4.330.0070.00015.00
7.4.320.0030.00616.87
7.4.300.0080.00016.69
7.4.290.0070.00316.70
7.4.280.0030.00916.67
7.4.270.0000.00916.75
7.4.260.0090.00016.75
7.4.250.0030.00616.75
7.4.240.0030.00616.72
7.4.230.0040.00416.84
7.4.220.0120.00916.70
7.4.210.0000.01916.85
7.4.200.0030.00616.84
7.4.160.0030.01616.79
7.4.150.0140.00717.40
7.4.140.0150.01017.86
7.4.130.0150.00816.81
7.4.120.0090.01616.73
7.4.110.0100.01616.87
7.4.100.0150.00816.71
7.4.90.0070.01316.84
7.4.80.0100.00519.39
7.4.70.0150.00616.59
7.4.60.0100.00916.70
7.4.50.0000.01116.79
7.4.40.0060.01216.77
7.4.30.0100.01016.83
7.4.10.0070.01415.13
7.4.00.0060.01415.10
7.3.330.0030.00613.60
7.3.320.0050.00213.60
7.3.310.0000.00916.66
7.3.300.0040.00416.68
7.3.290.0060.01216.60
7.3.280.0120.01016.59
7.3.270.0140.00717.40
7.3.260.0090.01216.62
7.3.250.0120.01216.81
7.3.240.0060.01516.54
7.3.230.0150.01116.64
7.3.210.0030.01816.66
7.3.200.0120.01419.39
7.3.190.0000.01916.55
7.3.180.0100.01016.85
7.3.170.0120.00816.89
7.3.160.0130.00716.91
7.3.130.0000.01914.91
7.3.120.0080.01315.26
7.3.110.0110.01014.94
7.3.100.0050.01114.83
7.3.90.0100.00815.09
7.3.80.0070.01115.13
7.3.70.0070.00915.05
7.3.60.0080.01014.84
7.3.50.0050.01014.75
7.3.40.0080.01115.10
7.3.30.0050.01315.04
7.3.20.0060.00916.66
7.3.10.0080.00916.64
7.3.00.0030.01016.63
7.2.330.0060.01616.74
7.2.320.0060.01417.01
7.2.310.0070.01317.05
7.2.300.0120.00916.97
7.2.290.0030.01616.77
7.2.260.0090.01215.59
7.2.250.0080.01315.38
7.2.240.0100.01215.48
7.2.230.0080.01015.34
7.2.220.0050.01315.38
7.2.210.0070.01015.53
7.2.200.0050.01315.28
7.2.190.0050.01415.28
7.2.180.0080.01115.41
7.2.170.0040.01115.37
7.2.160.0090.00715.44
7.2.150.0090.01017.02
7.2.140.0030.01316.93
7.2.130.0040.01417.14
7.2.120.0050.01316.97
7.2.110.0030.01216.67
7.2.100.0050.01516.89
7.2.90.0040.01716.94
7.2.80.0090.01016.79
7.2.70.0030.01217.04
7.2.60.0090.01116.96
7.2.50.0070.01016.78
7.2.40.0060.00917.07
7.2.30.0120.00417.01
7.2.20.0040.01216.80
7.2.10.0100.00716.72
7.2.00.0010.01417.64
7.1.330.0050.01515.76
7.1.320.0050.01415.84
7.1.310.0070.01215.81
7.1.300.0080.01315.87
7.1.290.0040.01415.81
7.1.280.0040.01315.78
7.1.270.0040.01315.67
7.1.260.0040.01615.61
7.1.250.0050.01115.90
7.1.240.0030.01615.71
7.1.230.0030.01015.79
7.1.220.0000.01615.95
7.1.210.0070.01315.72
7.1.200.0030.01215.75
7.1.190.0090.01015.83
7.1.180.0030.01615.66
7.1.170.0030.01615.95
7.1.160.0000.01715.87
7.1.150.0040.01115.96
7.1.140.0090.00915.69
7.1.130.0060.01315.92
7.1.120.0070.01715.87
7.1.110.0070.01715.97
7.1.100.0040.01417.10
7.1.90.0000.01215.88
7.1.80.0040.01215.81
7.1.70.0030.00916.56
7.1.60.0090.00917.59
7.1.50.0080.01316.39
7.1.40.0040.01415.74
7.1.30.0060.01215.66
7.1.20.0080.00815.86
7.1.10.0070.01415.96
7.1.00.0030.04519.22
7.0.330.0090.00915.50
7.0.320.0000.01515.56
7.0.310.0000.02015.18
7.0.300.0060.00915.18
7.0.290.0030.01315.07
7.0.280.0040.01415.18
7.0.270.0070.01015.41
7.0.260.0030.01515.21
7.0.250.0100.01015.41
7.0.240.0150.00915.55
7.0.230.0030.01015.19
7.0.220.0040.00815.29
7.0.210.0030.01515.55
7.0.200.0030.01216.18
7.0.190.0060.00615.48
7.0.180.0120.00615.50
7.0.170.0060.01315.26
7.0.160.0000.01415.63
7.0.150.0090.01515.61
7.0.140.0080.04618.57
7.0.130.0060.01315.60
7.0.120.0070.00715.45
7.0.110.0060.01615.32
7.0.100.0100.00715.59
7.0.90.0070.01115.22
7.0.80.0040.00815.52
7.0.70.0070.01315.48
7.0.60.0100.03817.67
7.0.50.0030.05516.62
7.0.40.0040.03416.87
7.0.30.0170.02217.03
7.0.20.0160.04316.66
7.0.10.0050.03816.79
7.0.00.0030.03816.88
5.6.400.0090.02715.54
5.6.390.0100.02415.82
5.6.380.0030.03115.80
5.6.370.0100.01915.48
5.6.360.0040.02815.46
5.6.350.0130.02015.49
5.6.340.0030.03015.45
5.6.330.0100.02115.42
5.6.320.0030.03315.77
5.6.310.0160.01915.67
5.6.300.0030.03215.88
5.6.290.0160.02315.48
5.6.280.0040.06118.85
5.6.270.0100.03415.41
5.6.260.0090.02815.82
5.6.250.0070.02915.45
5.6.240.0100.02015.54
5.6.230.0040.02915.33
5.6.220.0070.03015.54
5.6.210.0070.04518.61
5.6.200.0070.06017.21
5.6.190.0050.06518.33
5.6.180.0200.03818.36
5.6.170.0150.05218.51
5.6.160.0130.05518.45
5.6.150.0030.04217.28
5.6.140.0080.03317.32
5.6.130.0050.03917.27
5.6.120.0030.04518.75
5.6.110.0070.03718.81
5.6.100.0100.06218.76
5.6.90.0050.04018.87
5.6.80.0030.03818.59
5.6.70.2270.03918.49
5.6.60.0070.02315.34
5.6.50.0100.02415.55
5.6.40.0060.02915.48
5.6.30.0000.02915.34
5.6.20.0090.02215.36
5.6.10.0030.02915.12
5.6.00.0030.02315.37
5.5.380.0070.02315.65
5.5.370.0070.02615.45
5.5.360.0100.02615.17
5.5.350.0080.03518.52
5.5.340.0130.05617.16
5.5.330.0070.04018.28
5.5.320.0170.04318.33
5.5.310.0150.06318.28
5.5.300.0030.06017.25
5.5.290.0100.05717.28
5.5.280.0080.06418.54
5.5.270.0070.03618.60
5.5.260.0080.06518.79
5.5.250.0030.06718.50
5.5.240.0210.05718.40
5.5.230.0100.02615.34
5.5.220.0000.03015.05
5.5.210.0060.02215.21
5.5.200.0060.02515.23
5.5.190.0090.02115.52
5.5.180.0060.02515.57
5.5.170.0030.02815.44
5.5.160.0100.01715.63
5.5.150.0030.02815.16
5.5.140.0000.03315.52
5.5.130.0070.02915.57
5.5.120.0030.03515.26
5.5.110.0100.02415.47
5.5.100.0100.02015.29
5.5.90.0070.02115.28
5.5.80.0100.02415.46
5.5.70.0070.02915.35
5.5.60.0090.02215.42
5.5.50.0070.02515.23
5.5.40.0060.02515.17
5.5.30.0030.02715.40
5.5.20.0030.03515.38
5.5.10.0030.02715.31
5.5.00.0100.02215.18
5.4.450.0220.04116.35
5.4.440.0070.03516.38
5.4.430.0350.04916.32
5.4.420.0260.05116.43
5.4.410.0200.05616.35
5.4.400.0380.05516.12
5.4.390.0320.05415.96
5.4.380.0170.05215.83
5.4.370.0100.05515.93
5.4.360.0170.05315.86
5.4.350.0120.05315.89
5.4.340.0150.04915.93
5.4.330.0060.01811.96
5.4.320.0080.03212.84
5.4.310.0050.03912.71
5.4.300.0110.03512.96
5.4.290.0040.04412.98
5.4.280.0070.03612.85
5.4.270.0050.03412.88
5.4.260.0070.03612.87
5.4.250.0050.03812.83
5.4.240.0050.04012.84
5.4.230.0090.03412.89
5.4.220.0070.03712.81
5.4.210.0060.03412.85
5.4.200.0030.04012.86
5.4.190.0050.03812.81
5.4.180.0060.03512.86
5.4.170.0080.03712.77
5.4.160.0060.03712.89
5.4.150.0090.03312.87
5.4.140.0070.03412.66
5.4.130.0070.03812.75
5.4.120.0080.03712.77
5.4.110.0040.03912.55
5.4.100.0040.03712.63
5.4.90.0070.04112.63
5.4.80.0070.04012.58
5.4.70.0070.03712.63
5.4.60.0090.03112.51
5.4.50.0020.03812.60
5.4.40.0040.04112.51
5.4.30.0040.03712.61
5.4.20.0050.03512.66
5.4.10.0050.04512.68
5.4.00.0050.03612.38
5.3.290.0070.05013.84
5.3.280.0100.04713.77
5.3.270.0090.04913.78
5.3.260.0090.04913.77
5.3.250.0060.05313.77
5.3.240.0060.05213.77
5.3.230.0070.04913.77
5.3.220.0040.05213.74
5.3.210.0100.04713.73
5.3.200.0060.05213.74
5.3.190.0060.05113.73
5.3.180.0060.05013.73
5.3.170.0130.04613.73
5.3.160.0070.04913.73
5.3.150.0080.04913.73
5.3.140.0080.05313.73
5.3.130.0120.04713.72
5.3.120.0110.04713.71
5.3.110.0090.04913.72
5.3.100.0060.05013.21
5.3.90.0060.04913.20
5.3.80.0060.04713.18
5.3.70.0080.05113.18
5.3.60.0080.04713.16
5.3.50.0080.04713.12
5.3.40.0080.04813.12
5.3.30.0050.05513.08
5.3.20.0080.04612.85
5.3.10.0080.04612.82
5.3.00.0070.04812.80
5.2.170.0060.04510.33
5.2.160.0070.04310.33
5.2.150.0020.05410.32
5.2.140.0070.04610.32
5.2.130.0020.04910.28
5.2.120.0070.05610.28
5.2.110.0080.05410.29
5.2.100.0070.05110.28
5.2.90.0040.04610.28
5.2.80.0040.04710.27
5.2.70.0060.04410.28
5.2.60.0050.04410.23
5.2.50.0060.05110.20
5.2.40.0060.04610.17
5.2.30.0060.04610.02
5.2.20.0070.04110.01
5.2.10.0080.0399.91
5.2.00.0050.0989.55
5.1.60.0070.0379.38
5.1.50.0070.0449.38
5.1.40.0060.0399.36
5.1.30.0060.0419.71
5.1.20.0060.0449.73
5.1.10.0040.0439.46
5.1.00.0050.0429.46
5.0.50.0040.0627.94
5.0.40.0080.0667.80
5.0.30.0020.0707.61
5.0.20.0060.0747.58
5.0.10.0030.0617.55
5.0.00.0030.0717.55
4.4.90.0040.0204.78
4.4.80.0040.0174.75
4.4.70.0030.0164.75
4.4.60.0040.0154.75
4.4.50.0010.0194.77
4.4.40.0020.0314.71
4.4.30.0050.0154.76
4.4.20.0060.0174.84
4.4.10.0060.0164.85
4.4.00.0020.0314.76
4.3.110.0000.0244.67
4.3.100.0030.0154.67
4.3.90.0010.0164.63
4.3.80.0050.0254.58
4.3.70.0050.0164.63
4.3.60.0020.0174.63
4.3.50.0020.0164.63
4.3.40.0050.0234.53
4.3.30.0020.0163.32
4.3.20.0030.0153.30
4.3.10.0030.0153.25
4.3.00.0000.02018.16

preferences:
39.65 ms | 401 KiB | 5 Q