3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * A code sample which converts odd integers to word strings and returns the sum of the common factors of even numbers. * * The input is assumed to be a random list of integers. For the sum of the common factors of even numbers * only positive values are taken into consideration */ error_reporting(E_ALL); function exception_handler($exception) { echo get_class($exception). ' : ' . $exception->getMessage(), "\n"; } set_exception_handler('exception_handler'); //start $iB = new IntelligentBee(array(6,12,48, 7, 101, 67)); //$iB->processOddNumbers(); //$sum = $iB->processEvenNumbers(); //echo PHP_EOL.'Sum of common factors: ' . $sum . PHP_EOL; $a = $iB->getCmmdcSum(); echo PHP_EOL.' Sum is ' . $a[1]. PHP_EOL; //end class IntelligentBee{ const OneHundred = 100; const OneThousand = 1000; const OneMillion = 1000000; const OneBillion = 1000000000; protected $minCommonFactors = []; protected $oddNumbers = []; protected $evenNumbers = []; protected $startInt; protected $endInt; public function __construct(array $arrayOfIntegers){ $startInt = min($arrayOfIntegers); $endInt = max($arrayOfIntegers); if(abs($startInt) > self::OneBillion || abs($startInt) > self::OneBillion){ throw new OutOfRangeException(sprintf("We can only process numbers between %s and %s! %s provided!", self::OneBillion, self::OneBillion, $startInt)); } if(abs($endInt) > self::OneBillion || abs($endInt) > self::OneBillion){ throw new OutOfRangeException(sprintf("We can only process numbers between %s and %s! %s provided!", self::OneBillion, self::OneBillion, $startInt)); } $this->startInt = $startInt; $this->endInt = $endInt; $arrayOfIntegers = range(2, self::OneMillion,2); } public function getCmmdcSum() { $values = $this->evenNumbers; $num_values = count($values); $x = current($values); $y = next($values); for ($i = 1; $i < $num_values; $i ++) { $a = max($x, $y); $b = min($x, $y); $c= 1; do { $c = $a % $b; $gcf = $b; $a = $b; $b = $c; } while ($c != 0); $x = $gcf; $y = next($values); } $sum = 0; for($i = 1; $i <= $gcf; $i ++){ if(0 === $gcf % $i){ $sum += $i; } } return array($gcf, $sum); } }

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.0210.01024.00
8.3.50.0130.00826.00
8.3.40.0140.00726.06
8.3.30.0070.01426.67
8.3.20.0080.00427.91
8.3.10.0000.00931.70
8.3.00.0090.00328.52
8.2.180.0220.00923.88
8.2.170.0110.01126.54
8.2.160.0090.01228.10
8.2.150.0090.00326.70
8.2.140.0120.00026.61
8.2.130.0030.00630.36
8.2.120.0040.00428.93
8.2.110.0060.00330.18
8.2.100.0110.00725.34
8.2.90.0000.01326.86
8.2.80.0000.01124.97
8.2.70.0080.00425.38
8.2.60.0060.00625.67
8.2.50.0060.00625.25
8.2.40.0060.00327.98
8.2.30.0040.00725.80
8.2.20.0070.00425.30
8.2.10.0040.00725.77
8.2.00.0080.00425.23
8.1.280.0240.00731.13
8.1.270.0030.01038.96
8.1.260.0060.00336.73
8.1.250.0070.00739.12
8.1.240.0080.00839.16
8.1.230.0150.00834.27
8.1.220.0080.00832.80
8.1.210.0030.01332.61
8.1.200.0110.00732.61
8.1.190.0090.00932.60
8.1.180.0140.00732.60
8.1.170.0100.00733.89
8.1.160.0060.00937.18
8.1.150.0110.01133.77
8.1.140.0000.01432.66
8.1.130.0070.00733.06
8.1.120.0070.00732.64
8.1.110.0130.00332.80
8.1.100.0110.00332.77
8.1.90.0100.00732.63
8.1.80.0130.00332.79
8.1.70.0150.00032.63
8.1.60.0160.00032.93
8.1.50.0100.00632.80
8.1.40.0060.00932.70
8.1.30.0070.00732.79
8.1.20.0060.00932.84
8.1.10.0080.00832.72
8.1.00.0070.01032.59
8.0.300.0060.00932.27
8.0.290.0070.00732.30
8.0.280.0070.00733.46
8.0.270.0150.00032.24
8.0.260.0090.00432.37
8.0.250.0100.00331.95
8.0.240.0090.00632.10
8.0.230.0050.00932.15
8.0.220.0040.01131.95
8.0.210.0100.00331.93
8.0.200.0000.01332.16
8.0.190.0060.00932.17
8.0.180.0070.00732.02
8.0.170.0070.00732.05
8.0.160.0100.00432.01
8.0.150.0060.00932.02
8.0.140.0110.00431.98
8.0.130.0110.00428.53
8.0.120.0100.00732.09
8.0.110.0140.00332.00
8.0.100.0070.00732.10
8.0.90.0060.00932.03
8.0.80.0190.01631.96
8.0.70.0090.00631.89
8.0.60.0050.00932.12
8.0.50.0080.00832.02
8.0.30.0220.01532.08
8.0.20.0230.01332.20
8.0.10.0070.00731.99
8.0.00.0200.01831.95
7.4.330.0030.00630.03
7.4.320.0110.00331.54
7.4.300.0070.00731.63
7.4.290.0110.00431.64
7.4.280.0070.00731.73
7.4.270.0150.00031.73
7.4.260.0120.00931.59
7.4.250.0150.00031.49
7.4.240.0100.00431.69
7.4.230.0140.00031.61
7.4.220.0210.01831.67
7.4.210.0160.01731.68
7.4.200.0060.00931.55
7.4.190.0090.00631.67
7.4.160.0130.02031.63
7.4.150.0260.01031.74
7.4.140.0240.01731.67
7.4.130.0280.00631.59
7.4.120.0250.00931.67
7.4.110.0210.01131.44
7.4.100.0220.01331.68
7.4.90.0240.01231.75
7.4.80.0190.01631.53
7.4.70.0160.01931.77
7.4.60.0320.00331.59
7.4.50.0070.01131.71
7.4.40.0300.00331.64
7.4.30.0200.01331.49
7.4.10.0170.01729.97
7.4.00.0130.01630.12
7.3.330.0090.00328.40
7.3.320.0070.00728.36
7.3.310.0110.00431.46
7.3.300.0110.00431.44
7.3.290.0170.01331.44
7.3.280.0240.01431.47
7.3.270.0230.01331.51
7.3.260.0250.01231.64
7.3.250.0310.00831.47
7.3.240.0250.01131.70
7.3.230.0230.01331.51
7.3.210.0310.00931.47
7.3.200.0180.01731.79
7.3.190.0280.01231.73
7.3.180.0170.01731.35
7.3.170.0290.00631.38
7.3.160.0220.01231.39
7.3.130.0200.01429.63
7.3.120.0190.00829.95
7.3.110.0210.01029.86
7.3.100.0130.01329.78
7.3.90.0090.02029.79
7.3.80.0150.01229.76
7.3.70.0160.00729.94
7.3.60.0170.00929.82
7.3.50.0050.01829.83
7.3.40.0110.01229.80
7.3.30.0130.00829.80
7.3.20.0060.01432.39
7.3.10.0100.00732.62
7.3.00.0080.01232.56
7.2.330.0320.00331.80
7.2.320.0300.00631.98
7.2.310.0180.01631.70
7.2.300.0200.01331.93
7.2.290.0270.00931.66
7.2.260.0200.01330.08
7.2.250.0120.02030.25
7.2.240.0170.01230.22
7.2.230.0160.01430.21
7.2.220.0100.01530.21
7.2.210.0140.01130.09
7.2.200.0130.01230.10
7.2.190.0090.01830.07
7.2.180.0160.00930.14
7.2.170.0100.01629.98
7.2.160.0130.01330.31
7.2.150.0100.00632.36
7.2.140.0070.01732.64
7.2.130.0030.02032.81
7.2.120.0100.01032.61
7.2.110.0070.01732.86
7.2.100.0040.01532.61
7.2.90.0130.01332.51
7.2.80.0040.02533.00
7.2.70.0000.02032.97
7.2.60.0260.01032.63
7.2.50.0100.01332.87
7.2.40.0070.01432.95
7.2.30.0060.01332.79
7.2.20.0070.01632.75
7.2.10.0030.02432.84
7.2.00.0080.01034.11
7.1.330.0030.01631.79
7.1.320.0080.01231.79
7.1.310.0080.01231.86
7.1.300.0020.01431.52
7.1.290.0030.01731.74
7.1.280.0100.01031.80
7.1.270.0110.00731.55
7.1.260.0040.01531.71
7.1.250.0100.00731.54
7.1.240.0040.01531.86
7.1.230.0070.00731.61
7.1.220.0070.01331.73
7.1.210.0090.00931.47
7.1.200.0220.00731.75
7.1.190.0030.01431.58
7.1.180.0070.01131.70
7.1.170.0030.01231.82
7.1.160.0100.00731.54
7.1.150.0090.00931.83
7.1.140.0040.01531.67
7.1.130.0060.01931.75
7.1.120.0100.01031.77
7.1.110.0070.01031.90
7.1.100.0060.01132.78
7.1.90.0000.02031.86
7.1.80.0100.01031.54
7.1.70.0240.01632.36
7.1.60.0120.01732.41
7.1.50.0030.01432.15
7.1.40.0060.01031.59
7.1.30.0000.01831.81
7.1.20.0080.00831.56
7.1.10.0030.01431.59
7.1.00.0080.04535.01
7.0.330.0040.01831.39
7.0.320.0070.00731.34
7.0.310.0070.01831.42
7.0.300.0000.01931.11
7.0.290.0070.00731.45
7.0.280.0000.01431.39
7.0.270.0070.01331.16
7.0.260.0000.02131.38
7.0.250.0070.01031.32
7.0.240.0060.00931.42
7.0.230.0090.00931.40
7.0.220.0060.01631.35
7.0.210.0030.01731.16
7.0.200.0150.01032.00
7.0.190.0030.01031.46
7.0.180.0070.01131.23
7.0.170.0090.00931.50
7.0.160.0100.01031.30
7.0.150.0100.01331.48
7.0.140.0050.04734.58
7.0.130.0060.01231.46
7.0.120.0100.00731.46
7.0.110.0100.01031.27
7.0.100.0030.01731.46
7.0.90.0100.00331.40
7.0.80.0030.01331.45
7.0.70.0090.00631.18
7.0.60.0120.04433.31
7.0.50.0100.02532.23
7.0.40.0050.03032.27
7.0.30.0250.02832.32
7.0.20.0350.03932.19
7.0.10.0080.03332.05
7.0.00.0110.04932.35
5.6.400.0300.05379.30
5.6.390.0300.05078.92
5.6.380.0300.05079.28
5.6.370.0170.06878.73
5.6.360.0270.05078.95
5.6.350.0420.03579.07
5.6.340.0230.05478.70
5.6.330.0400.03779.04
5.6.320.0310.04578.82
5.6.310.0200.06379.21
5.6.300.0230.05579.34
5.6.290.0480.03779.27
5.6.280.0310.07682.28
5.6.270.0240.05079.09
5.6.260.0370.04779.08
5.6.250.0330.04778.95
5.6.240.0300.05078.98
5.6.230.0350.05479.05
5.6.220.0330.04678.92
5.6.210.0370.08882.21
5.6.200.0310.06580.88
5.6.190.0410.07881.92
5.6.180.0390.08182.07
5.6.170.0350.08782.03
5.6.160.0350.07682.13
5.6.150.0280.06180.95
5.6.140.0390.08080.88
5.6.130.0230.09181.02
5.6.120.0300.10082.27
5.6.110.0230.08582.35
5.6.100.0320.07582.37
5.6.90.0380.07582.42
5.6.80.0320.07981.96
5.6.70.0340.05578.75
5.6.60.0320.04579.20
5.6.50.0240.04779.25
5.6.40.0300.06778.98
5.6.30.0340.05779.00
5.6.20.0190.06278.92
5.6.10.0200.05678.72
5.6.00.0170.05778.88
5.5.380.0470.04479.29
5.5.370.0200.05179.29
5.5.360.0480.04179.07
5.5.350.1990.05882.03
5.5.340.0330.08380.63
5.5.330.0330.08382.00
5.5.320.0270.08281.79
5.5.310.0380.05881.88
5.5.300.0280.06080.72
5.5.290.0240.08780.92
5.5.280.0480.07382.29
5.5.270.0380.08582.20
5.5.260.0270.06682.23
5.5.250.0350.07082.16
5.5.240.0370.08981.93
5.5.230.0340.04778.79
5.5.220.0240.04878.80
5.5.210.0480.03178.95
5.5.200.0370.04378.94
5.5.190.0330.04478.80
5.5.180.0160.05978.80
5.5.170.0370.04078.85
5.5.160.0260.05978.86
5.5.150.0260.04978.99
5.5.140.0230.06378.57
5.5.130.0320.04578.79
5.5.120.0410.03879.02
5.5.110.0200.06379.06
5.5.100.0490.02678.73
5.5.90.0140.06178.99
5.5.80.0270.05479.09
5.5.70.0330.05979.05
5.5.60.0290.05578.83
5.5.50.0100.08378.88
5.5.40.0250.05379.18
5.5.30.0470.02778.87
5.5.20.0320.04878.91
5.5.10.0260.04678.71
5.5.00.0550.04879.04
5.4.450.0300.06379.95
5.4.440.0470.08079.94
5.4.430.0530.07779.84
5.4.420.0470.06079.72
5.4.410.0480.08779.85
5.4.400.0350.08579.76
5.4.390.0320.07679.66
5.4.380.0350.09179.74
5.4.370.0420.07779.64
5.4.360.0400.06179.58
5.4.350.0380.07879.62
5.4.340.0400.07979.79
5.4.330.0270.04775.46
5.4.320.0450.07479.79
5.4.310.0400.08279.74
5.4.300.0400.07579.78
5.4.290.0430.07479.68
5.4.280.0340.08979.80
5.4.270.0580.06779.67
5.4.260.0450.07279.74
5.4.250.0320.05879.67
5.4.240.0380.08879.68
5.4.230.0450.07379.69
5.4.220.0470.08079.70
5.4.210.0450.07579.77
5.4.200.0380.06679.70
5.4.190.0400.07079.60
5.4.180.0360.05979.89
5.4.170.0450.09279.57
5.4.160.0500.08479.51
5.4.150.0470.07779.63
5.4.140.0460.06678.43
5.4.130.0430.07678.42
5.4.120.0320.06778.36
5.4.110.0370.05778.19
5.4.100.0430.08278.46
5.4.90.0360.06678.25
5.4.80.0350.07778.38
5.4.70.0400.06578.34
5.4.60.0400.07378.30
5.4.50.0470.06778.41
5.4.40.0420.07778.27
5.4.30.0430.07878.32
5.4.20.0460.06978.36
5.4.10.0470.08078.50
5.4.00.0530.07378.11
5.3.290.0370.06714.57
5.3.280.0230.07714.50
5.3.270.0400.06014.51
5.3.260.0200.05714.50
5.3.250.0270.04714.60
5.3.240.0230.05014.52
5.3.230.0300.03314.56
5.3.220.0270.07014.49
5.3.210.0330.07314.58
5.3.200.0270.03314.64
5.3.190.0230.04014.79
5.3.180.0200.04314.58
5.3.170.0370.05714.64
5.3.160.0270.03714.64
5.3.150.0330.06014.68
5.3.140.0330.06314.55
5.3.130.0370.06314.47
5.3.120.0370.07014.55
5.3.110.0200.04314.46
5.3.100.0430.05714.20
5.3.90.0370.06713.94
5.3.80.0400.04313.94
5.3.70.0230.06313.92
5.3.60.0400.05313.91
5.3.50.0230.04013.88
5.3.40.0300.07313.96
5.3.30.0400.06013.82
5.3.20.0330.06313.77
5.3.10.0370.06313.66
5.3.00.0370.06713.54
5.2.170.0270.04712.06
5.2.160.0370.04712.06
5.2.150.0230.06012.06
5.2.140.0230.06012.06
5.2.130.0370.03312.06
5.2.120.0270.05012.06
5.2.110.0200.05312.06
5.2.100.0270.05712.06
5.2.90.0200.03712.06
5.2.80.0200.03012.06
5.2.70.0330.05712.06
5.2.60.0270.05312.06
5.2.50.0200.04012.06
5.2.40.0200.06012.06
5.2.30.0230.05712.06
5.2.20.0230.04712.06
5.2.10.0270.04312.06
5.2.00.0270.05012.06
5.1.60.0200.05012.06
5.1.50.0300.03712.06
5.1.40.0170.02712.06
5.1.30.0200.02312.06
5.1.20.0170.03712.06
5.1.10.0170.05312.06
5.1.00.0200.05012.06
5.0.50.0130.03312.06
5.0.40.0170.04012.06
5.0.30.0130.04012.06
5.0.20.0070.02312.06
5.0.10.0200.03312.06
5.0.00.0130.05312.06
4.4.90.0170.02712.06
4.4.80.0070.02712.06
4.4.70.0070.04012.06
4.4.60.0170.03012.06
4.4.50.0130.03012.06
4.4.40.0070.03712.06
4.4.30.0100.01712.06
4.4.20.0130.03312.06
4.4.10.0170.02312.06
4.4.00.0170.05012.06
4.3.110.0100.02712.06
4.3.100.0130.03012.06
4.3.90.0130.02312.06
4.3.80.0170.02712.06
4.3.70.0070.01712.06
4.3.60.0100.01312.06
4.3.50.0100.02312.06
4.3.40.0130.02312.06
4.3.30.0070.01712.06
4.3.20.0030.02712.06
4.3.10.0030.02312.06
4.3.00.0030.02012.06

preferences:
41.66 ms | 400 KiB | 5 Q