3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeAttachments($a, $b) { // If both #attached arrays contain drupalSettings, then merge them // correctly; adding the same settings multiple times needs to behave // idempotently. if (!empty($a['drupalSettings']) && !empty($b['drupalSettings'])) { $drupalSettings = mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE); // No need for re-merging them. unset($a['drupalSettings']); unset($b['drupalSettings']); } // Apply the normal merge. $a = mergeDeepArray(array($a, $b)); if (isset($drupalSettings)) { // Save the custom merge for the drupalSettings. $a['drupalSettings'] = $drupalSettings; } return $a; } function mergeAttachmentsOld($a, $b) { if (!empty($a['drupalSettings']) && !empty($b['drupalSettings'])) { $a['drupalSettings'] = mergeDeepArray([$a['drupalSettings'], $b['drupalSettings']], TRUE); unset($b['drupalSettings']); } return mergeDeep($a, $b); } function mergeDeepArray($arrays, $preserve_integer_keys = FALSE) { $result = array(); foreach ($arrays as $array) { foreach ($array as $key => $value) { // Renumber integer keys as array_merge_recursive() does unless // $preserve_integer_keys is set to TRUE. Note that PHP automatically // converts array keys that are integer strings (e.g., '1') to integers. if (is_integer($key) && !$preserve_integer_keys) { $result[] = $value; } // Recurse when both values are arrays. elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) { $result[$key] = mergeDeepArray(array($result[$key], $value), $preserve_integer_keys); } // Otherwise, use the latter value, overriding any previous value. else { $result[$key] = $value; } } } return $result; } function mergeDeep() { return mergeDeepArray(func_get_args()); } for($i = 0; $i <= 1000; $i++) { $a['#attached'] = array( 'library' => array( 'core/drupal', 'core/drupalSettings', ), ); $b['#attached'] = array( 'library' => array( 'core/jquery', ), ); mergeAttachments($a['#attached'], $b['#attached']); }

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.0190.00016.50
8.3.50.0130.00622.00
8.3.40.0140.01018.76
8.3.30.0170.00719.15
8.3.20.0080.00820.29
8.3.10.0070.01321.67
8.3.00.0080.00020.80
8.2.180.0160.00618.20
8.2.170.0090.01322.96
8.2.160.0110.01122.16
8.2.150.0070.01424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00321.18
8.2.110.0060.00320.52
8.2.100.0090.00317.72
8.2.90.0040.00419.17
8.2.80.0000.00917.97
8.2.70.0040.00417.50
8.2.60.0030.00717.93
8.2.50.0030.00618.07
8.2.40.0000.01020.07
8.2.30.0030.00718.21
8.2.20.0030.00517.78
8.2.10.0040.00418.07
8.2.00.0050.00517.75
8.1.280.0130.01025.92
8.1.270.0000.01120.78
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0100.00023.80
8.1.230.0030.00820.59
8.1.220.0090.00017.74
8.1.210.0050.00318.77
8.1.200.0090.00317.35
8.1.190.0000.00817.36
8.1.180.0080.00018.10
8.1.170.0040.00418.66
8.1.160.0000.00822.04
8.1.150.0000.00918.93
8.1.140.0030.00619.11
8.1.130.0000.00817.86
8.1.120.0000.00817.38
8.1.110.0090.00017.51
8.1.100.0000.00817.35
8.1.90.0060.00317.52
8.1.80.0030.00617.50
8.1.70.0000.00817.51
8.1.60.0000.00917.62
8.1.50.0000.00917.46
8.1.40.0000.00817.57
8.1.30.0000.00917.59
8.1.20.0030.00617.66
8.1.10.0000.00917.54
8.1.00.0130.00017.50
8.0.300.0050.00318.77
8.0.290.0030.00616.75
8.0.280.0070.00018.47
8.0.270.0050.00317.38
8.0.260.0030.00617.19
8.0.250.0070.00017.02
8.0.240.0030.00616.95
8.0.230.0040.00417.01
8.0.220.0000.00716.95
8.0.210.0000.00816.81
8.0.200.0040.00416.94
8.0.190.0030.00616.89
8.0.180.0030.00616.96
8.0.170.0000.00916.95
8.0.160.0040.00416.89
8.0.150.0000.00816.93
8.0.140.0000.00816.79
8.0.130.0060.00013.34
8.0.120.0030.00616.87
8.0.110.0040.00416.86
8.0.100.0050.00316.81
8.0.90.0030.00616.80
8.0.80.0100.00716.90
8.0.70.0040.00416.79
8.0.60.0030.00517.04
8.0.50.0060.00316.74
8.0.30.0130.01017.13
8.0.20.0090.01217.40
8.0.10.0040.00417.03
8.0.00.0160.00616.96
7.4.330.0060.00015.15
7.4.320.0020.00516.64
7.4.300.0000.00716.52
7.4.290.0070.00016.63
7.4.280.0000.00816.54
7.4.270.0040.00416.53
7.4.260.0000.00716.46
7.4.250.0040.00416.49
7.4.240.0060.00116.52
7.4.230.0030.00616.65
7.4.220.0110.00716.57
7.4.210.0130.01016.51
7.4.200.0080.00016.56
7.4.160.0100.00716.52
7.4.150.0120.01217.40
7.4.140.0110.00817.86
7.4.130.0080.01016.55
7.4.120.0070.01016.61
7.4.110.0070.02316.35
7.4.100.0120.00616.54
7.4.90.0090.01816.69
7.4.80.0130.01016.66
7.4.70.0120.00616.50
7.4.60.0150.00316.52
7.4.50.0030.00616.65
7.4.40.0090.01316.37
7.4.30.0130.01016.54
7.4.00.0030.01314.74
7.3.330.0000.00613.26
7.3.320.0040.00813.39
7.3.310.0040.00416.29
7.3.300.0000.00816.44
7.3.290.0040.01516.38
7.3.280.0090.01016.37
7.3.270.0330.02317.40
7.3.260.0080.01216.46
7.3.250.0070.01016.54
7.3.240.0060.01316.69
7.3.230.0030.01616.59
7.3.210.0090.00916.46
7.3.200.0110.00719.39
7.3.190.0150.00616.41
7.3.180.0080.00916.43
7.3.170.0070.01516.41
7.3.160.0140.01116.38
7.3.10.0030.01216.29
7.3.00.0000.01816.70
7.2.330.0130.00716.60
7.2.320.0060.01316.75
7.2.310.0060.01616.73
7.2.300.0090.00916.77
7.2.290.0000.01816.82
7.2.130.0090.00616.88
7.2.120.0060.00616.70
7.2.110.0040.01116.64
7.2.100.0040.01516.81
7.2.90.0030.01017.19
7.2.80.0090.00617.07
7.2.70.0070.00716.74
7.2.60.0030.01216.97
7.2.50.0060.01217.02
7.2.40.0000.01517.02
7.2.30.0060.00617.14
7.2.20.0090.00916.96
7.2.10.0070.00716.67
7.2.00.0090.00618.09
7.1.250.0030.01015.86
7.1.100.0000.01417.80
7.1.70.0000.00817.19
7.1.60.0100.01019.46
7.1.50.0060.01916.79
7.1.00.0030.07322.28
7.0.200.0110.00014.93
7.0.140.0070.03021.98
7.0.110.0200.09019.91
7.0.100.0230.07719.93
7.0.90.0230.08020.06
7.0.80.0200.05019.89
7.0.70.0230.08019.84
7.0.60.0170.08719.94
7.0.50.0200.08720.51
7.0.40.0070.08320.27
7.0.30.0030.08720.13
7.0.20.0030.06320.16
7.0.10.0100.08019.95
7.0.00.0100.08020.18
5.6.280.0000.08321.11
5.6.260.0170.06720.68
5.6.250.0100.07720.54
5.6.240.0070.08020.66
5.6.230.0070.08020.53
5.6.220.0100.07320.63
5.6.210.0100.07020.57
5.6.200.0130.08020.96
5.6.190.0100.08321.26
5.6.180.0030.09021.12
5.6.170.0100.08721.13
5.6.160.0030.09321.10
5.6.150.0230.07321.04
5.6.140.0030.07320.97
5.6.130.0070.08720.94
5.6.120.0130.09020.94
5.6.110.0200.04721.14
5.6.100.0030.08720.94
5.6.90.0130.08021.07
5.6.80.0070.08020.54
5.6.70.0100.08020.42
5.6.60.0000.05320.46
5.6.50.0030.08720.54
5.6.40.0100.08020.30
5.6.30.0070.08320.36
5.6.20.0130.05020.51
5.6.10.0130.07320.29
5.6.00.0070.05720.38
5.5.380.0130.07320.25
5.5.370.0000.08020.43
5.5.360.0170.08020.52
5.5.350.0130.07720.36
5.5.340.0100.08320.72
5.5.330.0070.08720.82
5.5.320.0070.09020.97
5.5.310.0100.06720.86
5.5.300.0200.06720.82
5.5.290.0100.08020.95
5.5.280.0070.08321.05
5.5.270.0070.09720.99
5.5.260.0070.08020.81
5.5.250.0030.09320.84
5.5.240.0100.08320.14
5.5.230.0100.08020.38
5.5.220.0030.04720.29
5.5.210.0070.08720.09
5.5.200.0070.09020.30
5.5.190.0170.05020.18
5.5.180.0130.08020.23
5.5.160.0030.08720.18
5.5.150.0100.08320.23
5.5.140.0030.08320.27
5.5.130.0070.08320.31
5.5.120.0170.08020.26
5.5.110.0100.08320.34
5.5.100.0030.09020.00
5.5.90.0030.08720.04
5.5.80.0100.07720.16
5.5.70.0130.08320.03
5.5.60.0130.07320.05
5.5.50.0100.08320.16
5.5.40.0130.07019.98
5.5.30.0070.08720.07
5.5.20.0170.04720.23
5.5.10.0130.06020.03
5.5.00.0070.08020.16
5.4.450.0200.06719.64
5.4.440.0100.08019.57
5.4.430.0070.08319.46
5.4.420.0100.07719.31
5.4.410.0170.07719.20
5.4.400.0130.07319.02
5.4.390.0070.04319.18
5.4.380.0100.07019.14
5.4.370.0070.07719.19
5.4.360.0070.09019.37
5.4.350.0130.07319.11
5.4.340.0130.07319.16
5.4.320.0030.07318.99
5.4.310.0130.05719.01
5.4.300.0130.07019.03
5.4.290.0070.08319.01
5.4.280.0100.05319.09
5.4.270.0070.08019.33
5.4.260.0070.07719.01
5.4.250.0100.07319.32
5.4.240.0100.07718.96
5.4.230.0230.06319.01
5.4.220.0100.08019.33
5.4.210.0070.08319.23
5.4.200.0070.07719.08
5.4.190.0230.06319.00
5.4.180.0070.08019.08
5.4.170.0030.07719.13
5.4.160.0070.08019.32
5.4.150.0070.05719.30
5.4.140.0170.04316.58
5.4.130.0000.06716.39
5.4.120.0070.07716.44
5.4.110.0100.07716.64
5.4.100.0100.07316.63
5.4.90.0000.07316.63
5.4.80.0070.08716.54
5.4.70.0100.07016.61
5.4.60.0070.03716.39
5.4.50.0070.07716.45
5.4.40.0130.06716.59
5.4.30.0070.07316.38
5.4.20.0100.03716.56
5.4.10.0070.07316.41
5.4.00.0170.06715.73
5.3.290.0130.04014.76
5.3.280.0030.04714.59
5.3.270.0070.07714.69
5.3.260.0070.07314.60
5.3.250.0070.07714.60
5.3.240.0130.07014.65
5.3.230.0100.07714.58
5.3.220.0000.07014.44
5.3.210.0100.07014.67
5.3.200.0130.07314.60
5.3.190.0100.04014.66
5.3.180.0100.07314.69
5.3.170.0030.03714.70
5.3.160.0100.07014.59
5.3.150.0070.07314.71
5.3.140.0000.07714.79
5.3.130.0100.07014.53
5.3.120.0100.06714.53
5.3.110.0070.07714.57
5.3.100.0100.06714.04
5.3.90.0070.06014.04
5.3.80.0130.07014.12
5.3.70.0070.07314.15
5.3.60.0030.08014.02
5.3.50.0030.06013.96
5.3.40.0030.08014.09
5.3.30.0100.04714.04
5.3.20.0030.07713.82
5.3.10.0100.06313.76
5.3.00.0070.07313.61
5.2.170.0130.05011.76
5.2.160.0070.06011.76
5.2.150.0070.05711.76
5.2.140.0030.05711.76
5.2.130.0070.06011.76
5.2.120.0070.05711.76
5.2.110.0000.03711.76
5.2.100.0070.06011.76
5.2.90.0030.06311.76
5.2.80.0070.06011.76
5.2.70.0030.06311.76
5.2.60.0130.04011.76
5.2.50.0070.05311.76
5.2.40.0100.05311.76
5.2.30.0070.05311.76
5.2.20.0000.04711.76
5.2.10.0130.05311.76
5.2.00.0130.04311.76
5.1.60.0030.05311.76
5.1.50.0000.04011.76
5.1.40.0130.04711.76
5.1.30.0030.05011.76
5.1.20.0100.05311.76
5.1.10.0100.02711.76
5.1.00.0100.04711.76
5.0.50.0000.05011.76
5.0.40.0030.04311.76
5.0.30.0100.05711.76
5.0.20.0000.04711.76
5.0.10.0030.04311.76
5.0.00.0000.03711.76
4.4.90.0070.03011.76
4.4.80.0030.02311.76
4.4.70.0000.03711.76
4.4.60.0070.03011.76
4.4.50.0030.03311.76
4.4.40.0030.05311.76
4.4.30.0030.03711.76
4.4.20.0000.03011.76
4.4.10.0030.03311.76
4.4.00.0070.02311.76
4.3.110.0030.03711.76
4.3.100.0070.01711.76
4.3.90.0070.02311.76
4.3.80.0000.04711.76
4.3.70.0070.03011.76
4.3.60.0000.03311.76
4.3.50.0000.03711.76
4.3.40.0030.04711.76
4.3.30.0000.01711.76
4.3.20.0000.03311.76
4.3.10.0000.03711.76
4.3.00.0030.02711.76

preferences:
51.29 ms | 401 KiB | 5 Q