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 = NestedArray::mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE); // No need for re-merging them. unset($a['drupalSettings']); unset($b['drupalSettings']); } // Apply the normal merge. $a = NestedArray::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 <= 100000; $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.0100.00716.62
8.3.50.0110.00821.88
8.3.40.0070.01118.93
8.3.30.0140.00719.10
8.3.20.0030.00620.30
8.3.10.0040.01121.95
8.3.00.0080.00020.80
8.2.180.0140.00018.50
8.2.170.0070.00722.96
8.2.160.0070.00722.26
8.2.150.0030.00525.66
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0060.01217.94
8.2.110.0100.00022.25
8.2.100.0040.00817.88
8.2.90.0000.00819.36
8.2.80.0050.00317.97
8.2.70.0050.00317.63
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0050.00318.04
8.2.20.0040.00417.71
8.2.10.0040.00418.18
8.2.00.0000.00817.84
8.1.280.0120.00925.92
8.1.270.0080.00020.68
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00023.92
8.1.230.0000.01119.18
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0050.00917.00
8.1.190.0040.00417.36
8.1.180.0030.00518.10
8.1.170.0000.00818.64
8.1.160.0000.00721.92
8.1.150.0040.00418.84
8.1.140.0070.00417.53
8.1.130.0070.00017.82
8.1.120.0000.00817.52
8.1.110.0030.00517.45
8.1.100.0040.00417.35
8.1.90.0000.00817.50
8.1.80.0050.00217.52
8.1.70.0000.00717.43
8.1.60.0040.00417.67
8.1.50.0040.00417.53
8.1.40.0040.00417.46
8.1.30.0040.00417.58
8.1.20.0040.00417.63
8.1.10.0040.00417.52
8.1.00.0060.00717.43
8.0.300.0000.00718.77
8.0.290.0040.00416.88
8.0.280.0030.00318.38
8.0.270.0070.00017.29
8.0.260.0070.00317.29
8.0.250.0000.00716.98
8.0.240.0060.00316.91
8.0.230.0000.00716.96
8.0.220.0060.00016.94
8.0.210.0000.00716.88
8.0.200.0000.00617.01
8.0.190.0000.00817.00
8.0.180.0070.00017.03
8.0.170.0030.00617.05
8.0.160.0050.00316.88
8.0.150.0070.00016.92
8.0.140.0040.00416.98
8.0.130.0030.00313.41
8.0.120.0040.00417.04
8.0.110.0070.00016.88
8.0.100.0050.00217.09
8.0.90.0030.00516.86
8.0.80.0060.00916.87
8.0.70.0040.00417.02
8.0.60.0070.00016.85
8.0.50.0040.00416.82
8.0.30.0100.00817.10
8.0.20.0150.00417.40
8.0.10.0040.00417.10
8.0.00.0090.01116.94
7.4.330.0050.00015.07
7.4.320.0030.00316.64
7.4.300.0030.00516.39
7.4.290.0030.00316.61
7.4.280.0040.00416.58
7.4.270.0000.00816.43
7.4.260.0030.00616.52
7.4.250.0040.00416.48
7.4.240.0030.00416.62
7.4.230.0000.00716.73
7.4.220.0100.00716.50
7.4.210.0150.00616.50
7.4.200.0030.00316.48
7.4.160.0060.01016.51
7.4.150.0090.00917.40
7.4.140.0120.00817.86
7.4.130.0060.01116.38
7.4.120.0080.00816.59
7.4.110.0140.00316.50
7.4.100.0140.01116.45
7.4.90.0060.01116.54
7.4.80.0090.00916.38
7.4.70.0140.00316.45
7.4.60.0070.01316.50
7.4.50.0000.00516.48
7.4.40.0100.00716.34
7.4.30.0090.01216.56
7.4.00.0060.01115.00
7.3.330.0050.00313.29
7.3.320.0070.00713.44
7.3.310.0000.00716.36
7.3.300.0030.00316.45
7.3.290.0080.00816.46
7.3.280.0060.01116.45
7.3.270.0070.01017.40
7.3.260.0040.01216.57
7.3.250.0120.00416.51
7.3.240.0140.00316.37
7.3.230.0140.00316.43
7.3.210.0160.00316.57
7.3.200.0110.00619.39
7.3.190.0100.01016.28
7.3.180.0120.00616.48
7.3.170.0040.01316.59
7.3.160.0070.01016.67
7.3.120.0090.00914.76
7.3.110.0100.00315.11
7.3.100.0100.00614.84
7.3.90.0120.00614.93
7.3.80.0130.00314.80
7.3.70.0100.00715.02
7.3.60.0030.01014.91
7.3.50.0080.00414.84
7.3.40.0080.00414.75
7.3.30.0030.00914.96
7.3.20.0070.00716.81
7.3.10.0160.00416.65
7.3.00.0110.00616.68
7.2.330.0110.00716.81
7.2.320.0100.00716.44
7.2.310.0090.00916.39
7.2.300.0120.00616.79
7.2.290.0130.00316.88
7.2.250.0040.01015.22
7.2.240.0080.00815.29
7.2.230.0090.00615.32
7.2.220.0040.01214.96
7.2.210.0030.01015.00
7.2.200.0110.00315.26
7.2.190.0000.01714.69
7.2.180.0060.01015.12
7.2.170.0060.00615.00
7.2.130.0060.01116.91
7.2.120.0110.00616.88
7.2.110.0090.00616.80
7.2.100.0140.00716.84
7.2.90.0080.01216.73
7.2.80.0090.00716.70
7.2.70.0090.00616.88
7.2.60.0080.00816.88
7.2.50.0100.00516.77
7.2.40.0070.00816.94
7.2.30.0060.00617.00
7.2.20.0060.00617.06
7.2.10.0020.01216.88
7.2.00.0060.00516.99
7.1.330.0070.00715.79
7.1.320.0090.00615.89
7.1.310.0130.00315.66
7.1.300.0060.00915.86
7.1.290.0070.00715.58
7.1.280.0060.00615.73
7.1.270.0100.00315.79
7.1.260.0040.00815.68
7.1.250.0090.00815.72
7.1.200.0060.00315.87
7.1.100.0000.01017.98
7.1.70.0050.00317.21
7.1.60.0060.01919.46
7.1.50.0100.01416.79
7.1.00.0070.06722.51
7.0.200.0030.00715.14
7.0.140.0030.07322.10
7.0.60.0100.03719.83
7.0.50.0030.04317.91
7.0.40.0000.05020.30
7.0.30.0070.04020.09
7.0.20.0100.04720.16
7.0.10.0000.04720.26
7.0.00.0070.09020.16
5.6.280.0030.07321.06
5.6.210.0130.06020.72
5.6.200.0100.08318.19
5.6.190.0070.05020.63
5.6.180.0300.08020.61
5.6.170.0230.08320.45
5.6.160.0000.09320.50
5.6.150.0000.05018.14
5.6.140.0070.08018.17
5.6.130.0000.04318.29
5.6.120.0100.06321.16
5.6.110.0030.07021.04
5.6.100.0070.04021.02
5.6.90.0070.06020.89
5.6.80.0030.04020.54
5.5.350.3230.03320.37
5.5.340.0070.08718.07
5.5.330.0100.04020.35
5.5.320.0300.07020.38
5.5.310.0370.06320.34
5.5.300.0100.07718.04
5.5.290.0100.06718.09
5.5.280.0070.04320.95
5.5.270.0000.08720.66
5.5.260.0230.06720.80
5.5.250.0100.06320.79
5.5.240.0270.06720.24
5.4.450.3030.04319.48
5.4.440.3370.03719.55
5.4.430.2800.04019.27
5.4.420.3000.04319.54
5.4.410.3000.04019.50
5.4.400.3030.03719.14
5.4.390.3030.03719.15
5.4.380.3000.04019.15
5.4.370.3100.03719.24
5.4.360.3030.03719.01
5.4.350.3030.03319.02
5.4.340.3000.03319.09
5.4.320.2530.03319.24
5.4.310.3330.04018.87
5.4.300.3030.04018.98
5.4.290.3270.03718.99
5.4.280.2900.04318.95
5.4.270.2970.04019.23
5.4.260.2970.04019.06
5.4.250.3300.03319.13
5.4.240.2800.04319.14
5.4.230.3930.03318.84
5.4.220.3170.04319.24
5.4.210.2930.04719.12
5.4.200.3000.03718.97
5.4.190.2730.03018.90
5.4.180.3030.04319.14
5.4.170.3030.03318.93
5.4.160.3030.03719.29
5.4.150.3300.04319.20
5.4.140.3100.03016.71
5.4.130.2470.04016.40
5.4.120.3200.03716.55
5.4.110.2600.03716.60
5.4.100.2970.03716.63
5.4.90.2970.03716.30
5.4.80.3230.03316.61
5.4.70.3000.04016.34
5.4.60.3270.03316.54
5.4.50.2500.04016.38
5.4.40.3000.03316.35
5.4.30.2870.03716.43
5.4.20.2770.03716.17
5.4.10.3070.03016.47
5.4.00.3270.03715.94
5.3.290.3270.04014.57
5.3.280.3030.03314.67
5.3.270.3470.05014.58
5.3.260.3270.03714.53
5.3.250.3200.04314.62
5.3.240.3630.03714.69
5.3.230.3270.03314.59
5.3.220.2670.04014.71
5.3.210.3070.03714.62
5.3.200.3230.03714.80
5.3.190.2830.03014.58
5.3.180.2730.04014.49
5.3.170.3200.04014.46
5.3.160.2900.04314.64
5.3.150.3030.04014.51
5.3.140.3070.03714.61
5.3.130.3270.04314.54
5.3.120.2930.03714.78
5.3.110.2930.04314.60
5.3.100.3370.03314.05
5.3.90.2630.04714.11
5.3.80.2800.03714.02
5.3.70.2800.04314.04
5.3.60.2570.04313.91
5.3.50.3130.03713.87
5.3.40.3200.03713.97
5.3.30.3300.03313.93
5.3.20.2930.03713.68
5.3.10.2700.03713.71
5.3.00.2700.03713.56
5.2.170.2200.03011.43
5.2.160.2400.03011.43
5.2.150.2470.03311.43
5.2.140.2500.03011.43
5.2.130.2070.02311.43
5.2.120.2530.02711.43
5.2.110.2570.02711.43
5.2.100.2470.03011.43
5.2.90.2030.02711.43
5.2.80.2600.03311.43
5.2.70.2270.03011.43
5.2.60.2330.02311.43
5.2.50.2300.02311.43
5.2.40.1930.03311.43
5.2.30.2030.03011.43
5.2.20.2030.02711.43
5.2.10.1970.03011.43
5.2.00.1970.03011.43
5.1.60.2100.02011.43
5.1.50.1500.02711.43
5.1.40.1570.02011.43
5.1.30.2000.02711.43
5.1.20.2030.02311.43
5.1.10.1570.02311.43
5.1.00.1830.02311.43
5.0.50.0970.02011.43
5.0.40.1000.03011.43
5.0.30.1230.02711.43
5.0.20.1000.02311.43
5.0.10.1070.01311.43
5.0.00.0700.03311.43
4.4.90.1070.01311.43
4.4.80.0970.01711.43
4.4.70.1270.01711.43
4.4.60.0970.01711.43
4.4.50.0700.01711.43
4.4.40.1030.02011.43
4.4.30.1000.01711.43
4.4.20.1230.02011.43
4.4.10.1270.01711.43
4.4.00.0970.02711.43
4.3.110.0800.01711.43
4.3.100.0870.01711.43
4.3.90.1030.01311.43
4.3.80.0970.03711.43
4.3.70.1230.02011.43
4.3.60.1230.01711.43
4.3.50.1270.02011.43
4.3.40.1100.02311.43
4.3.30.0670.02711.43
4.3.20.0630.02711.43
4.3.10.0770.02711.43
4.3.00.0830.01711.43

preferences:
43.14 ms | 401 KiB | 5 Q