3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iter = 0; function weight($array) { global $iter; $sum = array_sum($array); $rnd = mt_rand(0,$sum); foreach($array as $k=>$v) { $iter++; if($rnd <= $v) { return $k; } $rnd = $rnd - $v; } } $weights = range(0, 10000); $values = array_fill(0, count($weights), 0); for ($x = 0; $x < 1000; $x++) { $w = weight($weights); $values[$w] = $values[$w] + 1; } echo "$iter iterations performed"; var_dump($values);

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.4.00.0170.42615.23
7.3.120.0160.43815.46
7.3.110.0260.36415.50
7.3.100.0290.43315.36
7.3.90.0250.37315.18
7.3.80.0280.38615.26
7.3.70.0280.44115.27
7.3.60.0310.37515.27
7.3.50.0210.44415.37
7.3.40.0380.42315.15
7.3.30.0390.40515.37
7.3.20.0130.44016.58
7.3.10.0230.40416.35
7.3.00.0170.49416.45
7.2.250.0340.44115.57
7.2.240.0320.37015.61
7.2.230.0210.44115.45
7.2.220.0420.39515.65
7.2.210.0280.42315.59
7.2.200.0210.40915.53
7.2.190.0360.42715.57
7.2.180.0300.43815.52
7.2.170.0250.39815.46
7.2.160.0210.38115.58
7.2.150.0100.34816.67
7.2.140.0230.37216.74
7.2.130.0200.36316.67
7.2.120.0130.35316.73
7.2.110.0200.49516.86
7.2.100.0170.38016.79
7.2.90.0170.52116.80
7.2.80.0130.43116.87
7.2.70.0300.36317.05
7.2.60.0230.45216.97
7.2.50.0170.48616.63
7.2.40.0100.36716.75
7.2.30.0100.39716.85
7.2.20.0100.39816.95
7.2.10.0130.42716.90
7.2.00.0080.38618.08
7.1.330.0320.51914.97
7.1.320.0530.51515.07
7.1.310.0230.55115.29
7.1.300.0310.64815.19
7.1.290.0280.54115.14
7.1.280.0250.52615.56
7.1.270.0170.71715.71
7.1.260.0270.58715.62
7.1.250.0100.80315.98
7.1.240.0290.78215.55
7.1.230.0170.75315.73
7.1.220.0130.74415.75
7.1.210.0170.67715.71
7.1.200.0130.71915.83
7.1.190.0170.67215.62
7.1.180.0230.74815.73
7.1.170.0100.77615.85
7.1.160.0360.65315.91
7.1.150.0100.70715.50
7.1.140.0170.62315.54
7.1.130.0270.75315.80
7.1.120.0200.64515.65
7.1.110.0270.80915.87
7.1.100.0270.76215.74
7.1.90.0230.76415.81
7.1.80.0170.65715.79
7.1.70.0050.44116.59
7.1.60.0130.56317.43
7.1.50.0150.47116.48
7.1.40.0070.67015.80
7.1.30.0200.70415.76
7.1.20.0130.77215.78
7.1.10.0200.62915.92
7.1.00.0200.81515.59
7.0.330.0030.85015.46
7.0.320.0200.75115.43
7.0.310.0270.69615.37
7.0.300.0200.80715.45
7.0.290.0070.78015.51
7.0.280.0070.65315.44
7.0.270.0200.82115.53
7.0.260.0170.64115.48
7.0.250.0200.81315.55
7.0.240.0130.59415.61
7.0.230.0030.75015.34
7.0.220.0100.75815.47
7.0.210.0130.76215.40
7.0.200.0130.51316.03
7.0.190.0170.69715.47
7.0.180.0030.71415.71
7.0.170.0130.80115.66
7.0.160.0170.62015.38
7.0.150.0170.64615.55
7.0.140.0200.69515.67
7.0.130.0300.80015.48
7.0.120.0070.71015.39
7.0.110.0140.66415.26
7.0.100.0200.83115.38
7.0.90.0170.82515.38
7.0.80.0070.84615.63
7.0.70.0340.64915.45
7.0.60.0130.77415.53
7.0.50.0230.76715.70
7.0.40.0170.75713.32
7.0.30.0170.76813.38
7.0.20.0260.72113.68
7.0.10.0130.80213.64
7.0.00.0130.75513.47
5.6.400.0601.92518.03
5.6.390.0371.81418.23
5.6.380.0661.86717.79
5.6.370.0471.79118.03
5.6.360.0402.27517.94
5.6.350.0832.08718.13
5.6.340.0602.08418.03
5.6.330.0471.81617.66
5.6.320.0401.94718.05
5.6.310.0471.90318.13
5.6.300.0961.87717.66
5.6.290.0731.83417.83
5.6.280.0702.02518.07
5.6.270.0562.15918.01
5.6.260.0432.22418.38
5.6.250.0432.23818.22
5.6.240.0731.89517.77
5.6.230.1052.10118.25
5.6.220.0862.11117.87
5.6.210.0502.15118.06
5.6.200.0732.10017.63
5.6.190.1112.16418.10
5.6.180.0832.14618.24
5.6.170.0572.31417.76
5.6.160.0231.97117.83
5.6.150.0662.22618.28
5.6.140.0632.16218.14
5.6.130.1002.24217.94
5.6.120.0532.12217.97
5.6.110.0702.14218.11
5.6.100.0432.08817.98
5.6.90.0872.17517.78
5.6.80.0461.98517.96
5.6.70.0372.24717.87
5.6.60.0602.09117.84
5.6.50.0432.44017.65
5.6.40.0401.95117.71
5.6.30.0902.11817.93
5.6.20.0602.08218.24
5.6.10.0501.91618.12
5.6.00.0902.29517.78
5.5.380.0662.11217.92
5.5.370.0502.18518.00
5.5.360.0502.16118.13
5.5.350.0532.18117.84
5.5.340.0432.01818.32
5.5.330.0402.17218.02
5.5.320.0532.35618.05
5.5.310.0702.11717.92
5.5.300.0702.16417.95
5.5.290.0702.25917.77
5.5.280.0832.03718.18
5.5.270.0802.11717.51
5.5.260.0702.41717.53
5.5.250.0852.10018.05
5.5.240.0532.35718.00
5.5.230.0662.37217.65
5.5.220.1032.31117.61
5.5.210.0402.28118.20
5.5.200.0932.20818.00
5.5.190.0632.13618.11
5.5.180.0702.16717.66
5.5.170.0732.14217.80
5.5.160.0532.32517.82
5.5.150.0662.06417.59
5.5.140.0732.26618.09
5.5.130.0602.36117.80
5.5.120.0532.34718.10
5.5.110.1032.33518.04
5.5.100.0862.15817.64
5.5.90.0912.14317.82
5.5.80.1002.33017.90
5.5.70.0702.33917.92
5.5.60.0762.31317.78
5.5.50.0932.19417.99
5.5.40.0602.32117.75
5.5.30.0862.32117.71
5.5.20.0832.26418.05
5.5.10.0602.27717.66
5.5.00.1162.27617.89
5.4.450.0962.39814.88
5.4.440.0272.46814.95
5.4.430.0532.13414.61
5.4.420.0442.26114.85
5.4.410.0862.30614.68
5.4.400.0432.28414.79
5.4.390.0702.37814.88
5.4.380.0532.25414.91
5.4.370.0992.32714.55
5.4.360.0662.40814.75
5.4.350.0732.20414.82
5.4.340.0702.40414.86
5.4.330.0572.42014.77
5.4.320.0822.41114.81
5.4.310.0401.98814.75
5.4.300.0942.09714.78
5.4.290.0472.44614.46
5.4.280.0372.30014.84
5.4.270.0862.02814.72
5.4.260.0672.01614.54
5.4.250.0762.00614.53
5.4.240.0632.42814.93
5.4.230.0572.38314.88
5.4.220.0462.11614.57
5.4.210.0502.05314.70
5.4.200.0492.39914.50
5.4.190.0932.30814.75
5.4.180.0462.44814.86
5.4.170.0302.44614.96
5.4.160.0502.44614.66
5.4.150.0602.03214.68
5.4.140.0502.41214.80
5.4.130.1032.18314.44
5.4.120.0402.18614.70
5.4.110.0532.32514.72
5.4.100.0762.41614.70
5.4.90.0662.14014.87
5.4.80.0932.26614.82
5.4.70.0662.16714.73
5.4.60.0412.40014.86
5.4.50.0552.07014.85
5.4.40.0602.25714.67
5.4.30.0532.37514.70
5.4.20.0962.37814.78
5.4.10.0762.32814.69
5.4.00.0832.40914.73
5.3.290.0032.49013.94
5.3.280.0032.49213.67
5.3.270.0072.47413.68
5.3.260.0032.42713.88
5.3.250.0092.45313.84
5.3.240.0032.40513.69
5.3.230.0102.24913.83
5.3.220.0072.48813.76
5.3.210.0132.26613.56
5.3.200.0072.46013.80
5.3.190.0072.48613.86
5.3.180.0002.45613.86
5.3.170.0162.27713.82
5.3.160.0032.45713.96
5.3.150.0092.46913.92
5.3.140.0032.45713.87
5.3.130.0032.49113.89
5.3.120.0032.49013.89
5.3.110.0032.49113.94
5.3.100.0032.49113.71
5.3.90.0172.16213.68
5.3.80.0032.49113.54
5.3.70.0172.45013.77
5.3.60.0032.48913.76
5.3.50.0032.49113.79
5.3.40.0172.14713.72
5.3.30.0202.30513.77
5.3.20.0132.26013.72
5.3.10.0102.42113.55
5.3.00.0102.40113.56

preferences:
39.38 ms | 400 KiB | 5 Q