3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tstart = microtime(true); $numberOfRandoms = 5000; $uniques = array(); do { $uniques[mt_rand(10000, 99999)] = true; } while(count(array_keys($uniques)) < $numberOfRandoms); $uniques = array_keys($uniques); $elapsed = microtime(true) - $tstart; echo "hek2mgl:\t\t\t" . $elapsed . PHP_EOL; $tstart = microtime(true); $uniques = range(10000, 99999); shuffle($uniques); $uniques = array_slice($uniques, 0, $numberOfRandoms); $elapsed = microtime(true) - $tstart; echo "Dave Chen:\t\t\t" . $elapsed . PHP_EOL; $tstart = microtime(true); $uniques = array(); for($i = 0; $i < $numberOfRandoms; $i++) { do { $code = mt_rand(10000, 99999); } while(in_array($code, $uniques)); $uniques[] = $code; } $elapsed = microtime(true) - $tstart; echo "Josh from Qaribou:\t\t" . $elapsed . PHP_EOL;

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.00.0070.09723.05
7.1.70.0070.09121.26
7.1.60.0130.15520.86
7.1.50.0130.10520.87
7.1.00.0000.19326.48
7.0.200.2120.10618.04
7.0.140.0000.18325.92
7.0.60.0070.20023.23
7.0.50.0070.16721.11
7.0.40.0200.17322.36
7.0.30.0230.17022.15
7.0.20.0330.16022.23
7.0.10.0100.14722.48
7.0.00.0100.13722.28
5.6.280.0231.02335.06
5.6.210.0301.20734.55
5.6.200.0331.19332.07
5.6.190.0401.22334.25
5.6.180.0531.13334.14
5.6.170.0471.14734.23
5.6.160.0171.22734.38
5.6.150.0501.17332.15
5.6.140.0271.16732.06
5.6.130.0301.08032.11
5.6.120.0401.13734.97
5.6.110.0231.22035.00
5.6.100.0231.16735.02
5.6.90.0471.23034.95
5.6.80.0371.22034.27
5.6.70.4671.01734.36
5.5.350.0370.95734.42
5.5.340.0531.20031.91
5.5.330.0371.14334.24
5.5.320.0131.17734.10
5.5.310.0671.16334.02
5.5.300.0501.21331.88
5.5.290.0171.11331.93
5.5.280.0331.15034.75
5.5.270.0271.11334.74
5.5.260.0301.08034.75
5.5.250.0371.18334.60
5.5.240.0871.17034.26
5.4.450.1131.72033.28
5.4.440.0701.82733.54
5.4.430.0931.84733.37
5.4.420.0771.84733.36
5.4.410.0771.73732.93
5.4.400.0501.75733.04
5.4.390.0801.86033.04
5.4.380.0801.84733.13
5.4.370.0671.69732.76
5.4.360.1001.48732.68
5.4.350.0901.76732.82
5.4.340.0801.91032.93
5.4.320.0321.19426.46
5.4.310.0391.18426.45
5.4.300.0331.23726.46
5.4.290.0411.21526.45
5.4.280.0791.54526.33
5.4.270.0471.83033.03
5.4.260.0691.55226.32
5.4.250.0771.65032.93
5.4.240.0671.67032.93
5.4.230.0731.78732.96
5.4.220.0671.80732.98
5.4.210.0721.80926.32
5.4.200.0522.02726.32
5.4.190.0431.35526.32
5.4.180.0781.81926.31
5.4.170.1112.00926.33
5.4.160.0901.87032.95
5.4.150.0962.10926.32
5.4.140.0982.03726.00
5.4.130.1171.71330.25
5.4.120.0882.04625.95
5.4.110.0601.94330.18
5.4.100.0772.17425.95
5.4.90.0952.07125.93
5.4.80.0771.69030.45
5.4.70.0462.09126.14
5.4.60.0542.03925.93
5.4.50.0631.86030.07
5.4.40.0331.82826.13
5.4.30.0771.65030.44
5.4.20.0962.08825.91
5.4.10.0651.83425.91
5.4.00.0371.72329.79
5.3.290.0221.21726.66
5.3.280.0271.67926.57
5.3.270.0272.05126.59
5.3.260.0341.88526.59
5.3.250.0271.69526.59
5.3.240.0251.50926.59
5.3.230.0321.55026.58
5.3.220.0321.85526.55
5.3.210.0601.90028.19
5.3.200.0231.68326.55
5.3.190.0332.02728.27
5.3.180.0241.93826.55
5.3.170.0291.95726.54
5.3.160.0251.90926.54
5.3.150.0421.87826.54
5.3.140.0301.81026.54
5.3.130.0261.84626.53
5.3.120.0321.87526.53
5.3.110.0301.55926.53
5.3.100.0221.84926.02
5.3.90.0411.43426.00
5.3.80.0291.92525.99
5.3.70.0251.99325.98
5.3.60.0451.94425.97
5.3.50.0381.48425.92
5.3.40.0381.72525.92
5.3.30.0151.73626.10
5.3.20.0501.82327.45
5.3.10.0571.66327.37
5.3.00.0271.79027.38
5.2.170.1302.30324.09
5.2.160.1272.29323.99
5.2.150.0172.20724.20
5.2.140.0372.29324.43
5.2.130.1732.12024.04
5.2.120.1371.76012.24
5.2.110.1681.88322.26
5.2.100.1632.25323.94
5.2.90.1471.87022.25
5.2.80.1171.91022.25
5.2.70.1381.93522.25
5.2.60.1602.25023.99
5.2.50.1432.29011.84
5.2.40.1272.31712.11
5.2.30.1302.31311.98
5.2.20.1432.20711.98
5.2.10.2701.88012.05
5.2.00.2561.82721.87
5.1.60.0072.37711.49
5.1.50.0332.39311.45
5.1.40.0332.39327.33
5.1.30.0332.43727.98
5.1.20.0432.37311.82
5.1.10.0302.39311.66
5.1.00.0372.36327.47
5.0.50.0202.41325.96
5.0.40.0172.4339.96
5.0.30.0132.43725.77
5.0.20.0202.43025.51
5.0.10.0402.3779.77
5.0.00.0302.42025.59
4.4.90.0102.4407.60
4.4.80.0172.4307.40
4.4.70.0132.3907.42
4.4.60.0232.2337.42
4.4.50.0032.0407.36
4.4.40.0172.4077.48
4.4.30.0132.42723.39
4.4.20.0072.4307.46
4.4.10.0202.42023.40
4.4.00.0072.40323.37
4.3.110.0272.4307.41
4.3.100.0272.43323.28
4.3.90.0272.43023.39
4.3.80.0202.41723.21
4.3.70.0272.40313.23
4.3.60.0132.45723.28
4.3.50.0332.3577.47
4.3.40.0272.40323.34
4.3.30.0132.4136.08
4.3.20.0032.4506.16
4.3.10.0402.37013.63
4.3.00.0202.47321.88

preferences:
38.17 ms | 401 KiB | 5 Q