3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iter = 0; function weight($array) { global $iter = 0; $sum = array_sum($array); $rnd = mt_rand(0,$sum); foreach($array as $k=>$v) { $iter++; if($rnd <= $v) { return $k; } $rnd = $rnd - $v; } } $weights = [100, 200, 1000]; $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);

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.280.0050.05112.39
5.4.270.0070.05012.39
5.4.260.0090.05412.39
5.4.250.0100.06512.40
5.4.240.0100.06112.40
5.4.230.0090.05212.39
5.4.220.0120.04912.38
5.4.210.0120.05612.39
5.4.200.0080.05512.39
5.4.190.0110.05212.38
5.4.180.0120.06012.38
5.4.170.0130.05212.39
5.4.160.0110.05212.38
5.4.150.0120.04612.38
5.4.140.0080.05712.08
5.4.130.0150.05112.05
5.4.120.0100.05012.02
5.4.110.0070.05112.02
5.4.100.0090.05412.02
5.4.90.0100.04912.02
5.4.80.0070.04712.02
5.4.70.0090.04712.01
5.4.60.0080.05012.01
5.4.50.0090.06012.01
5.4.40.0090.05612.00
5.4.30.0090.05212.00
5.4.20.0100.05411.99
5.4.10.0050.04212.00
5.4.00.0070.04211.49
5.3.280.0060.05612.71
5.3.270.0080.04912.72
5.3.260.0100.05412.72
5.3.250.0120.05912.72
5.3.240.0090.04512.72
5.3.230.0090.05912.71
5.3.220.0110.04812.68
5.3.210.0140.05812.68
5.3.200.0080.05912.68
5.3.190.0070.04512.68
5.3.180.0080.03812.67
5.3.170.0050.04112.67
5.3.160.0070.03812.67
5.3.150.0120.04812.67
5.3.140.0090.04812.66
5.3.130.0090.04912.66
5.3.120.0090.04112.66
5.3.110.0080.04312.66
5.3.100.0090.03712.12
5.3.90.0090.05712.09
5.3.80.0090.06812.09
5.3.70.0070.03812.08
5.3.60.0080.05212.07
5.3.50.0060.06312.01
5.3.40.0100.04612.01
5.3.30.0130.04311.97
5.3.20.0100.06711.75
5.3.10.0140.05911.72
5.3.00.0120.05211.71
5.2.170.0070.0359.20
5.2.160.0110.0329.20
5.2.150.0080.0369.20
5.2.140.0070.0389.20
5.2.130.0090.0349.16
5.2.120.0060.0349.16
5.2.110.0040.0379.16
5.2.100.0070.0349.16
5.2.90.0080.0379.16
5.2.80.0080.0439.15
5.2.70.0060.0369.16
5.2.60.0090.0349.11
5.2.50.0070.0369.08
5.2.40.0050.0369.06
5.2.30.0050.0389.03
5.2.20.0050.0349.02
5.2.10.0090.0328.93
5.2.00.0070.0398.80
5.1.60.0070.0258.08
5.1.50.0090.0348.08
5.1.40.0060.0328.05
5.1.30.0080.0438.41
5.1.20.0090.0318.43
5.1.10.0090.0398.15
5.1.00.0070.0348.15
5.0.50.0180.0456.63
5.0.40.0140.0366.49
5.0.30.0070.0386.30
5.0.20.0150.0396.27
5.0.10.0040.0336.25
5.0.00.0070.0386.24
4.4.90.0040.0244.78
4.4.80.0050.0314.76
4.4.70.0060.0424.76
4.4.60.0030.0214.76
4.4.50.0070.0304.77
4.4.40.0030.0314.70
4.4.30.0020.0204.76
4.4.20.0030.0214.85
4.4.10.0030.0224.85
4.4.00.0040.0324.76
4.3.110.0040.0184.67
4.3.100.0040.0244.67
4.3.90.0090.0194.64
4.3.80.0050.0284.58
4.3.70.0050.0184.63
4.3.60.0040.0204.63
4.3.50.0050.0234.63
4.3.40.0080.0294.54
4.3.30.0080.0253.30
4.3.20.0060.0233.28
4.3.10.0040.0233.24
4.3.00.0170.0238.47

preferences:
140.57 ms | 1386 KiB | 7 Q