3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getNumbers($count) { $numbers = range(1, $count); shuffle($numbers); return $numbers; } function sumOfRemaindersOriginal($numbers) { $resSum = 0; $len = count($numbers); if($len == 1) return 0; for($i=0; $i<$len; $i++) for($j=0; $j<$len; $j++) $resSum += $numbers[$i]%$numbers[$j]; return $resSum; } function sumOfRemainders($numbers) { $sum = 0; if (1 === count($numbers)) { return 0; } foreach ($numbers as $a) foreach ($numbers as $b) $sum += $a % $b; return $sum; } print "Setting up "; $start = microtime(true); $numbers = getNumbers(2000); $end = microtime(true); print count($numbers) . " numbers in " . ($end - $start) . "\n"; print "Running 'sumOfRemaindersOriginal' in "; $start = microtime(true); $x = sumOfRemaindersOriginal($numbers); $end = microtime(true); print ($end - $start) . " Result: " . $x . "\n"; print "Running 'sumOfRemainders' in "; $start = microtime(true); $x = sumOfRemainders($numbers); $end = microtime(true); $time = $end - $start; print ($end - $start) . " Result: " . $x . "\n";

Abusive script

This script was stopped while abusing our resources

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)
7.2.20.0150.49019.97
7.2.10.0130.49119.45
7.2.00.0140.45119.88
7.1.140.0120.46318.53
7.1.130.0140.51618.77
7.1.120.0150.44118.66
7.1.110.0100.48318.15
7.1.100.0120.51917.97
7.1.90.0090.48018.21
7.1.80.0080.48518.14
7.1.70.0080.47717.10
7.1.60.0330.48734.93
7.1.50.0280.49534.78
7.1.40.0260.50034.46
7.1.30.0320.51034.38
7.1.20.0320.52934.76
7.1.10.0090.47316.62
7.1.00.0110.47716.68
7.0.270.0090.60418.31
7.0.260.0110.61518.23
7.0.250.0060.59217.81
7.0.240.0120.57517.66
7.0.230.0090.54117.79
7.0.220.0080.57417.74
7.0.210.0080.53616.59
7.0.200.0070.47516.80
7.0.190.0100.60916.68
7.0.180.0090.60416.18
7.0.170.0100.59516.24
7.0.160.0110.59316.33
7.0.150.0090.59216.38
7.0.140.0110.57216.29
7.0.130.0060.53116.63
7.0.120.0110.62716.53
7.0.110.0090.53116.41
7.0.100.0100.52516.27
7.0.90.0090.49916.43
7.0.80.0100.57716.33
7.0.70.0130.67416.18
7.0.60.0090.68316.12
7.0.50.0080.53416.49
7.0.40.0150.48415.48
7.0.30.0210.58015.52
7.0.20.0110.60215.67
7.0.10.0110.58915.77
7.0.00.0130.58815.67
5.6.300.0201.19421.29
5.6.290.0191.26121.23
5.6.280.0201.29221.38
5.6.270.0231.26721.31
5.6.260.0211.23121.48
5.6.250.0171.24121.42
5.6.240.0231.22221.43
5.6.230.0191.26521.35
5.6.220.0261.48221.26
5.6.210.0271.53521.27
5.6.200.0221.20221.34
5.6.190.0401.30921.29
5.6.180.0221.24721.37
5.6.170.0311.37921.27
5.6.160.0201.40121.42
5.6.150.0241.20121.30
5.6.140.0251.42021.34
5.6.130.0261.32521.27
5.6.120.0211.31821.33
5.6.110.0181.38921.44
5.6.100.0271.22021.25
5.6.90.0331.35021.31
5.6.80.0251.27720.84
5.6.70.0241.34120.65
5.6.60.0261.16520.73
5.6.50.0251.20020.68
5.6.40.0201.26320.75
5.6.30.0211.24020.70
5.6.20.0261.32520.76
5.6.10.0201.28520.70
5.6.00.0201.20520.64
5.5.380.0201.33517.89
5.5.370.0231.21617.90
5.5.360.0231.51318.04
5.5.350.0191.24318.07
5.5.340.0121.09718.52
5.5.330.0191.32918.29
5.5.320.0201.27318.29
5.5.310.0221.36318.59
5.5.300.0171.14018.22
5.5.290.0141.24618.57
5.5.280.0291.34118.50
5.5.270.0241.24618.50
5.5.260.0211.20918.57
5.5.250.0281.29818.32
5.5.240.0201.32917.90
5.5.230.0171.08917.67
5.5.220.0181.12017.86
5.5.210.0191.20317.89
5.5.200.0141.05917.80
5.5.190.0181.20917.86
5.5.180.0211.17117.63
5.5.160.0181.18817.88
5.5.150.0241.48817.83
5.5.140.0201.28717.86
5.5.130.0511.26217.54
5.5.120.0231.36517.88
5.5.110.0211.27917.76
5.5.100.0171.29817.52
5.5.90.0171.16417.82
5.5.80.0151.40517.73
5.5.70.0211.18517.54
5.5.60.0141.25417.68
5.5.50.0131.13217.69
5.5.40.0151.12917.79
5.5.30.0151.15317.64
5.5.20.0171.22917.46
5.5.10.0191.49817.81
5.5.00.0181.25817.74
5.4.450.0181.22219.82
5.4.440.0201.15019.73
5.4.430.0181.10819.93
5.4.420.0311.16319.87
5.4.410.0161.08719.59
5.4.400.0121.10519.62
5.4.390.0141.09019.33
5.4.380.0161.11419.50
5.4.370.0211.08919.42
5.4.360.0201.06819.41
5.4.350.0141.21819.55
5.4.340.0191.29319.39
5.4.320.0151.12919.31
5.4.310.0191.42319.45
5.4.300.0161.29019.49
5.4.290.0241.29819.30
5.4.280.0241.41719.39
5.4.270.0201.33819.30
5.4.260.0241.37619.30
5.4.250.0251.28119.27
5.4.240.0221.12819.49
5.4.230.0111.13219.27
5.4.220.0211.30519.57
5.4.210.0191.14119.48
5.4.200.0181.10119.54
5.4.190.0191.16019.60
5.4.180.0211.40919.53
5.4.170.0201.15919.32
5.4.160.0231.16719.45
5.4.150.0191.39119.40
5.4.140.0251.25817.11
5.4.130.0121.17717.08
5.4.120.0211.34317.00
5.4.110.0161.22016.96
5.4.100.0241.22617.20
5.4.90.0181.23816.93
5.4.80.0161.29016.93
5.4.70.0141.18517.12
5.4.60.0201.31417.21
5.4.50.0131.26717.02
5.4.40.0161.22416.91
5.4.30.0261.13217.01
5.4.20.0281.19217.06
5.4.10.0251.25617.03
5.4.00.0161.16216.43
5.3.290.0121.32015.51
5.3.280.0181.27615.53
5.3.270.0201.27615.55
5.3.260.0231.35415.53
5.3.250.0221.70115.44
5.3.240.0141.33915.25
5.3.230.0231.33115.54
5.3.220.0481.40915.44
5.3.210.0201.41615.21
5.3.200.0161.52215.49
5.3.190.0171.32815.51
5.3.180.0151.37515.41
5.3.170.0191.42215.21
5.3.160.0191.47115.27
5.3.150.0181.46915.50
5.3.140.0181.45415.26
5.3.130.0241.33615.31
5.3.120.0201.32215.50
5.3.110.0281.55015.39
5.3.100.0141.38414.73
5.3.90.0171.27914.86
5.3.80.0151.25314.95
5.3.70.0131.26014.84
5.3.60.0171.22114.84
5.3.50.0271.32014.59
5.3.40.0131.29314.71
5.3.30.0201.21414.61
5.3.20.0181.27714.39
5.3.10.0191.23814.29
5.3.00.0171.22414.16
5.2.170.0151.67711.56
5.2.160.0131.62411.63
5.2.150.0091.52611.98
5.2.140.0141.52111.66
5.2.130.0081.63411.56
5.2.120.0161.53711.51
5.2.110.0131.59011.34
5.2.100.0231.88311.55
5.2.90.0211.75111.68
5.2.80.0221.72011.50
5.2.70.0201.99811.59
5.2.60.0151.63211.89
5.2.50.0271.98611.48
5.2.40.0232.20411.28
5.2.30.0191.68611.25
5.2.20.0151.40711.54
5.2.10.0161.44111.34
5.2.00.0141.43311.21
5.1.60.0141.48410.85
5.1.50.0081.32110.79
4.4.90.0072.4508.44
4.4.80.0132.3958.44
4.4.70.0092.4408.44
4.4.60.0112.4258.44
4.4.50.0112.4348.44
4.4.40.0162.4408.44

preferences:
46.21 ms | 403 KiB | 5 Q