3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = []; for ($i = 0; $i < 3000; $i++) { $items[] = [ 'foo' => 1, 'qty' => ($i%7)+1, 'bar' => 2, 'weight' => ($i%2)+1, 'baz' => 3, ]; } $start =microtime(1); $weights =array_unique(array_column($items, 'weight')); $result =[]; Foreach($weights as $weight){ $weightitems = array_filter($items, function ($var) use ($weight) { return ($var['weight'] == $weight); }); $result[] = array_sum(array_column($weightitems, "qty")) * $weight; } Echo array_sum($result) ."\n"; Echo (microtime(1)-$start)*100;

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.0.00.0160.01317.93
7.4.130.0130.01017.58
7.4.120.0140.01417.66
7.4.110.0030.01917.89
7.4.100.0190.00617.85
7.4.90.0160.01417.93
7.4.80.0170.01018.12
7.4.70.0230.00717.86
7.4.60.0130.01617.79
7.4.50.0120.01217.86
7.4.40.0060.01917.88
7.4.30.0130.01017.89
7.4.20.0160.00617.75
7.4.10.0140.01417.92
7.4.00.0130.01417.06
7.3.250.0070.02017.66
7.3.240.0100.01417.81
7.3.230.0090.01817.86
7.3.220.0200.00017.75
7.3.210.0090.01417.80
7.3.200.0190.00917.96
7.3.190.0070.01517.75
7.3.180.0130.01417.92
7.3.170.0180.00317.70
7.3.160.0080.01617.90
7.3.150.0100.01117.95
7.3.140.0100.01917.71
7.3.130.0100.01017.95
7.3.120.0110.00817.16
7.3.110.0100.00917.16
7.3.100.0080.01317.07
7.3.90.0070.01217.17
7.3.80.0140.00616.96
7.3.70.0140.00717.04
7.3.60.0080.01217.11
7.3.50.0070.01117.00
7.3.40.0080.01316.94
7.3.30.0060.01116.99
7.3.20.0090.00917.30
7.3.10.0110.00717.05
7.3.00.0100.00717.11
7.2.340.0130.00918.28
7.2.330.0150.00718.05
7.2.320.0140.01418.31
7.2.310.0170.01418.25
7.2.300.0100.01318.34
7.2.290.0180.01517.86
7.2.280.0120.01518.32
7.2.270.0210.00418.09
7.2.260.0240.00618.39
7.2.250.0090.01517.22
7.2.240.0110.01317.49
7.2.230.0090.01017.22
7.2.220.0050.01517.35
7.2.210.0080.01317.40
7.2.200.0040.01617.46
7.2.190.0090.01117.33
7.2.180.0110.00517.19
7.2.170.0070.01217.42
7.2.160.0260.00317.95
7.2.150.0160.00918.18
7.2.140.0170.00918.27
7.2.130.0090.01117.46
7.2.120.0130.01117.60
7.2.110.0070.01017.57
7.2.100.0180.01117.60
7.2.90.0070.01117.61
7.2.80.0080.01017.71
7.2.70.0130.01117.61
7.2.60.0100.00917.61
7.2.50.0180.00917.66
7.2.40.0130.00718.44
7.2.30.0130.01218.33
7.2.20.0250.01418.29
7.2.10.0140.01318.21
7.2.00.0120.01018.33
7.1.330.0080.01717.58
7.1.320.0110.01017.46
7.1.310.0070.01417.53
7.1.300.0050.01617.56
7.1.290.0120.01117.39
7.1.280.0180.01717.51
7.1.270.0130.01017.46
7.1.260.0120.00817.52
7.1.250.0110.01017.55
7.1.240.0090.01817.18
7.1.230.0040.02117.23
7.1.220.0130.01617.18
7.1.210.0150.00717.07
7.1.200.0120.01217.14
7.1.190.0170.00717.17
7.1.180.0080.01717.14
7.1.170.0120.01517.20
7.1.160.3260.01417.89
7.1.150.0190.01517.97
7.1.140.0300.02017.79
7.1.130.0170.01317.88
7.1.120.0190.01317.91
7.1.110.0160.01617.63
7.1.100.0190.01817.47
7.1.90.2780.01617.45
7.1.80.1360.01317.72
7.1.70.2280.01617.21
7.1.60.1380.01726.16
7.1.50.1830.01326.10
7.1.40.1930.01325.96
7.1.30.1790.01425.87
7.1.20.2050.01326.00
7.1.10.1710.01416.93
7.1.00.2280.01516.95
7.0.330.0340.00716.85
7.0.320.0290.00717.05
7.0.310.0270.01216.77
7.0.300.0370.01316.79
7.0.290.0320.01216.70
7.0.280.0290.01116.89
7.0.270.0510.02316.89
7.0.260.0300.01316.79
7.0.250.0390.02716.95
7.0.240.0180.02216.91
7.0.230.0210.00516.88
7.0.220.0310.00417.02
7.0.210.0170.01416.86
7.0.200.0000.02716.95
7.0.190.0170.01716.94
7.0.180.0150.01217.02
7.0.170.0150.01716.99
7.0.160.0260.00016.96
7.0.150.0210.00816.87
7.0.140.0150.01616.84
7.0.130.0160.01716.86
7.0.120.0170.01416.76
7.0.110.0220.00316.91
7.0.100.0160.01217.00
7.0.90.0100.01716.92
7.0.80.0310.02416.89
7.0.70.0230.01116.91
7.0.60.0220.01316.83
7.0.50.0170.02016.90
7.0.40.0200.01216.94
7.0.30.0230.01016.65
7.0.20.0230.01316.81
7.0.10.0290.01316.75
7.0.00.0140.01916.96
5.6.400.0220.03319.79
5.6.390.0300.02419.71
5.6.380.0250.02519.83
5.6.370.0260.03919.50
5.6.360.0390.02719.48
5.6.350.0220.04419.89
5.6.340.0200.04419.48
5.6.330.0330.03119.76
5.6.320.0210.04719.88
5.6.310.0230.02919.91
5.6.300.0140.03119.69
5.6.290.0190.02819.79
5.6.280.0230.02319.43
5.6.270.0130.02619.82
5.6.260.0190.02819.53
5.6.250.0140.03319.43
5.6.240.0190.03019.54
5.6.230.0290.01619.62
5.6.220.0160.04019.65
5.6.210.0150.03719.82
5.6.200.0130.03519.84
5.6.190.0150.03019.65
5.6.180.0170.03119.55
5.6.170.0170.03319.52
5.6.160.0360.03719.74
5.6.150.0290.02719.67
5.6.140.0240.02419.73
5.6.130.0230.02719.58
5.6.120.0250.02519.69
5.6.110.0100.03819.47
5.6.100.0330.01619.66
5.6.90.0220.02219.65
5.6.80.0150.03019.80
5.6.70.0210.03019.60
5.6.60.0170.04119.61
5.6.50.0170.02719.43
5.6.40.0200.03119.46
5.6.30.0270.03119.51
5.6.20.0260.03619.61
5.6.10.0090.03819.23
5.6.00.0320.03519.21
5.5.380.0450.04019.92
5.5.370.0170.04319.61
5.5.360.0150.03919.58
5.5.350.0200.03919.61
5.5.340.0260.04519.67
5.5.330.0210.04619.60
5.5.320.0260.02319.85
5.5.310.0280.02119.44
5.5.300.0240.02419.88
5.5.290.0150.05319.66
5.5.280.0260.03219.69
5.5.270.0180.03319.92
5.5.260.0300.02119.76
5.5.250.0230.02819.29
5.5.240.0230.02319.62
5.5.230.0240.02419.45
5.5.220.0300.02719.40
5.5.210.0320.03219.68
5.5.200.0320.03519.35
5.5.190.0230.03019.55
5.5.180.0350.04919.61
5.5.170.0310.03319.54
5.5.160.0230.04919.72
5.5.150.0220.03819.70
5.5.140.0300.03419.52
5.5.130.0320.03519.60
5.5.120.0330.04019.31
5.5.110.0160.04919.48
5.5.100.0340.04019.66
5.5.90.0410.02419.63
5.5.80.0250.04319.57
5.5.70.0340.03819.44
5.5.60.0290.02819.27
5.5.50.0170.03619.59
5.5.40.0360.03619.50
5.5.30.0190.03419.58
5.5.20.0360.02219.44
5.5.10.0310.02819.36
5.5.00.0260.03519.69
5.4.450.0220.01815.49
5.4.440.0150.01515.66
5.4.430.0220.01015.70
5.4.420.0190.01315.47
5.4.410.0160.01315.70
5.4.400.0190.00915.48
5.4.390.0180.01115.63
5.4.380.0230.00615.64
5.4.370.0260.00715.63
5.4.360.0180.01715.19
5.4.350.0280.01015.40
5.4.340.0230.01615.49
5.4.330.0180.02215.24
5.4.320.0200.01815.44
5.4.310.0180.02115.68
5.4.300.0170.01715.62
5.4.290.0220.01315.57
5.4.280.0200.02015.57
5.4.270.0200.02015.34
5.4.260.0230.02015.43
5.4.250.0190.01615.42
5.4.240.0250.01415.54
5.4.230.0220.01515.50
5.4.220.0220.01215.66
5.4.210.0230.01015.46
5.4.200.0220.01615.30
5.4.190.0270.01015.35
5.4.180.0120.02415.42
5.4.170.0220.01115.57
5.4.160.0250.01115.47
5.4.150.0150.01915.78
5.4.140.0280.01115.70
5.4.130.0250.00915.62
5.4.120.0190.01515.48
5.4.110.0230.02515.28
5.4.100.0240.01415.48
5.4.90.0170.01415.33
5.4.80.0280.02315.39
5.4.70.0280.00815.66
5.4.60.0220.01215.45
5.4.50.0290.00015.57
5.4.40.0160.01615.29
5.4.30.0270.00315.60
5.4.20.0240.00815.36
5.4.10.0190.01215.54
5.4.00.0180.00915.48
5.3.290.0350.00612.70
5.3.280.0220.00612.66
5.3.270.0190.00712.59
5.3.260.0210.00412.65
5.3.250.0140.01412.65
5.3.240.0230.00612.53
5.3.230.0170.01312.68
5.3.220.0220.00612.61
5.3.210.0120.01612.57
5.3.200.0200.01012.78
5.3.190.0210.00312.70
5.3.180.0180.01213.05
5.3.170.0150.00912.95
5.3.160.0160.01212.81
5.3.150.0180.00912.95
5.3.140.0190.00512.70
5.3.130.0170.01012.76
5.3.120.0170.00712.65
5.3.110.0230.00712.88
5.3.100.0140.01012.70
5.3.90.0170.00812.79
5.3.80.0090.01412.59
5.3.70.0180.01012.73
5.3.60.0200.00812.82
5.3.50.0170.00812.71
5.3.40.0140.01012.81
5.3.30.0200.00312.56
5.3.20.0200.00712.68
5.3.10.0240.00012.46
5.3.00.0040.01912.51
5.2.170.0100.01011.74
5.2.160.0090.01311.73
5.2.150.0140.00711.88
5.2.140.0170.00611.79
5.2.130.0110.00911.76
5.2.120.0150.00611.73
5.2.110.0140.00711.79
5.2.100.0170.00711.85
5.2.90.0170.00711.84
5.2.80.0100.01511.72
5.2.70.0140.01111.61
5.2.60.0080.01211.76
5.2.50.0160.01011.65
5.2.40.0250.00011.69
5.2.30.0210.00411.75
5.2.20.0150.00511.61
5.2.10.0210.00411.72
5.2.00.0130.01011.60
5.1.60.0090.01310.92
5.1.50.0080.01110.92
5.1.40.0100.01011.16
5.1.30.0140.00510.97
5.1.20.0140.00510.92
5.1.10.0140.00710.92
5.1.00.0140.00310.92
5.0.50.0060.01210.92
5.0.40.0110.00710.92
5.0.30.0150.00310.92
5.0.20.0110.00710.92
5.0.10.0120.00510.92
5.0.00.0120.00610.92
4.4.90.0120.00010.92
4.4.80.0070.00510.92
4.4.70.0070.00210.92
4.4.60.0070.00310.92
4.4.50.0120.00010.92
4.4.40.0060.00610.92
4.4.30.0040.00810.92
4.4.20.0080.00310.92
4.4.10.0120.00010.92
4.4.00.0060.00410.92
4.3.110.0100.00010.92
4.3.100.0070.00310.92
4.3.90.0070.00210.92
4.3.80.0070.00310.92
4.3.70.0090.00310.92
4.3.60.0100.00310.92
4.3.50.0080.00410.92
4.3.40.0100.00210.92
4.3.30.0000.00810.92
4.3.20.0060.00310.92
4.3.10.0000.01010.92
4.3.00.0040.00410.92

preferences:
30.96 ms | 403 KiB | 5 Q