3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?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)
5.4.320.0120.03112.50
5.4.310.0090.03612.49
5.4.300.0030.04212.50
5.4.290.0080.03712.49
5.4.280.0140.04412.39
5.4.270.0070.05012.39
5.4.260.0060.04412.39
5.4.250.0090.03412.39
5.4.240.0080.03412.39
5.4.230.0040.04012.38
5.4.220.0060.03612.38
5.4.210.0050.03612.38
5.4.200.0110.03212.38
5.4.190.0080.03412.38
5.4.180.0060.03612.38
5.4.170.0040.03912.39
5.4.160.0090.03912.38
5.4.150.0090.03312.38
5.4.140.0050.03912.07
5.4.130.0110.03812.05
5.4.120.0100.03212.01
5.4.110.0080.03312.01
5.4.100.0120.03012.01
5.4.90.0120.03112.01
5.4.80.0110.03212.01
5.4.70.0070.03412.01
5.4.60.0060.03412.01
5.4.50.0030.03712.00
5.4.40.0060.03411.99
5.4.30.0050.03811.99
5.4.20.0090.03811.98
5.4.10.0080.03711.99
5.4.00.0060.03711.48
5.3.290.0050.04012.80
5.3.280.0050.03812.71
5.3.270.0070.03812.72
5.3.260.0070.04012.72
5.3.250.0110.03312.71
5.3.240.0050.03812.71
5.3.230.0080.04112.70
5.3.220.0070.03712.68
5.3.210.0060.03812.68
5.3.200.0050.03712.68
5.3.190.0090.03512.68
5.3.180.0070.03512.68
5.3.170.0100.03112.67
5.3.160.0060.03612.68
5.3.150.0070.04812.67
5.3.140.0050.03812.66
5.3.130.0080.03612.66
5.3.120.0090.03612.66
5.3.110.0080.03712.66
5.3.100.0040.03912.12
5.3.90.0080.03412.08
5.3.80.0090.03312.07
5.3.70.0060.03612.07
5.3.60.0120.03212.06
5.3.50.0090.03312.00
5.3.40.0100.03312.00
5.3.30.0080.03311.95
5.3.20.0060.03411.73
5.3.10.0130.02811.70
5.3.00.0070.03611.68
5.2.170.0070.0349.18
5.2.160.0030.0349.18
5.2.150.0060.0299.18
5.2.140.0070.0289.18
5.2.130.0050.0299.14
5.2.120.0050.0289.14
5.2.110.0050.0299.14
5.2.100.0040.0299.14
5.2.90.0100.0259.14
5.2.80.0040.0319.14
5.2.70.0030.0339.14
5.2.60.0060.0299.09
5.2.50.0090.0269.05
5.2.40.0050.0299.03
5.2.30.0090.0279.02
5.2.20.0040.0299.00
5.2.10.0060.0268.93
5.2.00.0070.0288.79
5.1.60.0060.0228.07
5.1.50.0060.0238.06
5.1.40.0070.0228.05
5.1.30.0040.0268.40
5.1.20.0080.0238.42
5.1.10.0050.0258.14
5.1.00.0050.0258.14
5.0.50.0040.0206.63
5.0.40.0100.0196.48
5.0.30.0070.0336.29
5.0.20.0030.0196.27
5.0.10.0050.0186.24
5.0.00.0030.0306.23
4.4.90.0020.0154.78
4.4.80.0040.0134.75
4.4.70.0030.0154.76
4.4.60.0030.0154.76
4.4.50.0030.0174.77
4.4.40.0020.0254.71
4.4.30.0050.0124.76
4.4.20.0020.0154.84
4.4.10.0020.0164.85
4.4.00.0020.0254.76
4.3.110.0010.0174.67
4.3.100.0020.0154.66
4.3.90.0010.0154.64
4.3.80.0020.0254.58
4.3.70.0040.0134.63
4.3.60.0020.0154.63
4.3.50.0050.0134.63
4.3.40.0050.0214.54
4.3.30.0020.0163.28
4.3.20.0020.0173.26
4.3.10.0010.0223.22
4.3.00.0000.02018.16

preferences:
143.35 ms | 1394 KiB | 7 Q