3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [.1, .2, .7]; function weightedSelector($input, $value){ foreach ($input as $key => $value){ $total = array_sum($input); $previous = array_sum(array_slice($input, 0, $key)); $percentage = $total - $previous; print_r($total." ".$previous." ".$percentage); if ($value <= $percentage){ return $key; } } } foreach ([.1, .15, .2, .29, .3, .4, .5, .8, .99, .66] as $value){ // print_r(weightedSelector($input, $value)." : ".$value); // print_r("\n"); }

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.0150.00316.75
8.3.50.0170.00316.20
8.3.40.0120.00918.66
8.3.30.0120.00618.64
8.3.20.0040.00421.73
8.3.10.0080.00023.66
8.3.00.0040.00417.78
8.2.180.0040.01118.41
8.2.170.0150.00022.96
8.2.160.0030.01020.32
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0090.00019.22
8.2.120.0100.00326.35
8.2.110.0040.00421.02
8.2.100.0060.00617.66
8.2.90.0030.00619.21
8.2.80.0080.00019.76
8.2.70.0060.00317.80
8.2.60.0040.00417.91
8.2.50.0000.00718.10
8.2.40.0040.00420.45
8.2.30.0000.00719.41
8.2.20.0030.00317.96
8.2.10.0000.00717.85
8.2.00.0000.00818.05
8.1.280.0120.00825.92
8.1.270.0080.00022.09
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00623.84
8.1.230.0110.00022.68
8.1.220.0000.00717.74
8.1.210.0050.00318.77
8.1.200.0060.00317.35
8.1.190.0000.00817.00
8.1.180.0070.00018.10
8.1.170.0000.00818.78
8.1.160.0040.00418.73
8.1.150.0000.00719.03
8.1.140.0000.00817.58
8.1.130.0060.00319.11
8.1.120.0000.00717.32
8.1.110.0060.00317.36
8.1.100.0070.00017.27
8.1.90.0000.00717.28
8.1.80.0040.00417.27
8.1.70.0040.00417.39
8.1.60.0090.00017.46
8.1.50.0000.00817.36
8.1.40.0040.00417.46
8.1.30.0040.00417.59
8.1.20.0030.00617.59
8.1.10.0060.00317.48
8.1.00.0040.00717.46
8.0.300.0000.00719.97
8.0.290.0030.00616.63
8.0.280.0040.00418.24
8.0.270.0030.00317.09
8.0.260.0030.00318.99
8.0.250.0050.00316.88
8.0.240.0000.00716.87
8.0.230.0030.00516.84
8.0.220.0080.00016.71
8.0.210.0000.00716.77
8.0.200.0030.00316.84
8.0.190.0000.00716.77
8.0.180.0030.00316.89
8.0.170.0060.00316.85
8.0.160.0000.00716.71
8.0.150.0000.00716.79
8.0.140.0050.00216.82
8.0.130.0000.00613.28
8.0.120.0000.00816.69
8.0.110.0000.00716.83
8.0.100.0040.00416.71
8.0.90.0000.00816.69
8.0.80.0110.00416.86
8.0.70.0030.00516.76
8.0.60.0040.00416.84
8.0.50.0050.00316.64
8.0.30.0110.00717.09
8.0.20.0100.00917.40
8.0.10.0050.00316.98
8.0.00.0080.01016.64
7.4.330.0000.00515.55
7.4.320.0030.00316.41
7.4.300.0030.00316.42
7.4.290.0030.00316.44
7.4.280.0040.00416.45
7.4.270.0000.00716.55
7.4.260.0030.00316.50
7.4.250.0070.00016.41
7.4.240.0050.00316.54
7.4.230.0000.00716.53
7.4.220.0000.00716.46
7.4.210.0070.00816.52
7.4.200.0030.00316.41
7.4.160.0070.00916.40
7.4.140.0090.01117.86
7.4.130.0140.00316.48
7.4.120.0100.01016.44
7.4.110.0110.00716.43
7.4.100.0060.01216.60
7.4.90.0080.00916.44
7.4.80.0090.01319.39
7.4.70.0030.01316.42
7.4.60.0110.00416.45
7.4.50.0120.00616.58
7.4.40.0130.00916.48
7.4.10.0070.01416.39
7.4.00.0050.01215.49
7.3.330.0000.00613.16
7.3.320.0000.00613.16
7.3.310.0070.00016.32
7.3.300.0000.00716.21
7.3.290.0000.00716.13
7.3.280.0080.00816.28
7.3.260.0100.00816.40
7.3.240.0110.00816.33
7.3.230.0040.01516.28
7.3.210.0100.00616.43
7.3.200.0140.00716.21
7.3.190.0070.01016.33
7.3.180.0060.01216.35
7.3.170.0110.00616.49
7.3.160.0130.00316.32
7.3.130.0100.01016.48
7.3.120.0070.00915.49
7.3.110.0120.00315.47
7.3.100.0000.01515.62
7.3.90.0110.00615.52
7.3.80.0060.00815.81
7.3.70.0050.00815.42
7.3.60.0040.00615.53
7.3.50.0080.00615.43
7.3.40.0070.00915.45
7.3.30.0050.00815.57
7.3.20.0050.00717.20
7.3.10.0050.00917.32
7.3.00.0060.00517.39
7.2.330.0120.00916.57
7.2.320.0080.00816.48
7.2.310.0100.00716.61
7.2.300.0130.01016.45
7.2.290.0120.00916.40
7.2.260.0180.00316.46
7.2.250.0100.01115.75
7.2.240.0050.01515.88
7.2.230.0070.00815.64
7.2.220.0050.00815.85
7.2.210.0070.00715.74
7.2.200.0060.00615.72
7.2.190.0080.00515.73
7.2.180.0020.01315.66
7.2.170.0110.00515.68
7.2.160.0040.00716.45
7.2.150.0120.00418.23
7.2.140.0070.00718.36
7.2.130.0060.00318.38
7.2.120.0070.01018.28
7.2.110.0070.01018.33
7.2.100.0070.01018.36
7.2.90.0060.01518.34
7.2.80.0150.00618.28
7.2.70.0000.01318.29
7.2.60.0060.00817.44
7.2.50.0080.00717.54
7.2.40.0620.01018.12
7.2.30.0600.01218.10
7.2.20.0540.01218.16
7.2.10.0340.01017.97
7.2.00.0460.01018.21
7.1.330.0120.00316.49
7.1.320.0090.00316.51
7.1.310.0070.00816.56
7.1.300.0070.00416.36
7.1.290.0060.00616.48
7.1.280.0050.00916.42
7.1.270.0070.00516.23
7.1.260.0060.00616.32
7.1.250.0030.01617.34
7.1.240.0090.00917.07
7.1.230.0110.00417.13
7.1.220.0090.00317.31
7.1.210.0100.00717.30
7.1.200.0030.00616.43
7.1.190.0000.01117.10
7.1.180.0120.00417.26
7.1.170.0060.00917.28
7.1.160.0530.00816.97
7.1.150.0490.00416.81
7.1.140.0390.01116.84
7.1.130.0860.01817.05
7.1.120.0520.00816.91
7.1.110.0640.01016.57
7.1.100.0710.01016.79
7.1.90.0600.00816.70
7.1.80.0820.00616.79
7.1.70.0340.01016.25
7.1.60.0750.01225.22
7.1.50.0510.01024.92
7.1.40.0610.00724.83
7.1.30.0540.01024.82
7.1.20.0480.01224.91
7.1.10.0740.00915.97
7.1.00.0330.00615.87
7.0.330.0070.01016.84
7.0.320.0100.00616.84
7.0.310.0030.01316.89
7.0.300.0060.00916.87
7.0.290.0070.00716.91
7.0.280.0030.01017.06
7.0.270.0000.01116.92
7.0.260.0060.00616.91
7.0.250.0120.00316.92
7.0.240.0070.00716.85
7.0.230.0060.00316.98
7.0.220.0000.01016.77
7.0.210.0030.01016.87
7.0.200.0070.01016.93
7.0.190.0130.00316.86
7.0.180.0070.01116.83
7.0.170.0070.01116.96
7.0.160.0040.01116.83
7.0.150.0030.00916.88
7.0.140.0070.01016.84
7.0.130.0060.00917.02
7.0.120.0070.00716.87
7.0.110.0070.00716.78
7.0.100.0040.00816.91
7.0.90.0040.01116.99
7.0.80.0060.00616.94
7.0.70.0070.00716.84
7.0.60.0070.00716.74
7.0.50.0060.00316.90
7.0.40.0060.00314.89
7.0.30.0000.01414.86
7.0.20.0100.00314.89
7.0.10.0110.00614.78
7.0.00.0070.00714.86
5.6.400.0070.00716.17
5.6.390.0060.01215.76
5.6.380.0030.01416.00
5.6.370.0070.00715.89
5.6.360.0080.00815.85
5.6.350.0090.00615.72
5.6.340.0120.00416.22
5.6.330.0070.00716.21
5.6.320.0070.00715.94
5.6.310.0070.00715.91
5.6.300.0030.01015.64
5.6.290.0060.00615.52
5.6.280.0060.01016.15
5.6.270.0090.00915.89
5.6.260.0090.00315.96
5.6.250.0140.00015.71
5.6.240.0060.00915.90
5.6.230.0000.01215.95
5.6.220.0000.01315.77
5.6.210.0070.00715.85
5.6.200.0030.01315.84
5.6.190.0040.01116.04
5.6.180.0060.00915.96
5.6.170.0040.00815.68
5.6.160.0070.01016.16
5.6.150.0100.00715.64
5.6.140.0120.00415.85
5.6.130.0030.00615.78
5.6.120.0040.00815.86
5.6.110.0030.01016.03
5.6.100.0040.01115.81
5.6.90.0070.01116.20
5.6.80.0050.00515.59
5.6.70.0060.00315.78
5.6.60.0120.00316.08
5.6.50.0060.00615.93
5.6.40.0000.01215.61
5.6.30.0000.01115.80
5.6.20.0040.00415.86
5.6.10.0080.00415.57
5.6.00.0000.01015.72

preferences:
32.02 ms | 400 KiB | 5 Q