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'])) { $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', ), 'drupalSettings' => [ 'bar' => ['a', 'b', 'c'], ], 'js' => array( 'baz.js' => array(), ), ); $b['#attached'] = array( 'library' => array( 'core/jquery', ), 'js' => array( 'foo.js' => array(), 'bar.js' => array(), ), 'drupalSettings' => [ 'foo' => ['d'], ], ); 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.21716.50
8.3.50.0170.20121.98
8.3.40.0100.17118.84
8.3.30.0070.17819.04
8.3.20.0100.11520.39
8.3.10.0030.09721.91
8.3.00.0030.13820.69
8.2.180.0030.18816.75
8.2.170.0130.17422.96
8.2.160.0070.17922.30
8.2.150.0070.09424.18
8.2.140.0030.10424.66
8.2.130.0000.10126.16
8.2.120.0030.11618.09
8.2.110.0030.20522.13
8.2.100.0070.16717.63
8.2.90.0030.16718.97
8.2.80.0000.16717.97
8.2.70.0000.17017.63
8.2.60.0100.15717.93
8.2.50.0000.16818.07
8.2.40.0030.16118.16
8.2.30.0000.19018.02
8.2.20.0070.16317.77
8.2.10.0070.16418.21
8.2.00.0030.16717.77
8.1.280.0030.19125.92
8.1.270.0100.12820.68
8.1.260.0100.08626.35
8.1.250.0030.09828.09
8.1.240.0100.19623.98
8.1.230.0070.14319.01
8.1.220.0030.16717.74
8.1.210.0060.16418.77
8.1.200.0070.16617.48
8.1.190.0070.16317.13
8.1.180.0100.16018.10
8.1.170.0070.14918.52
8.1.160.0070.14621.91
8.1.150.0070.16018.82
8.1.140.0000.16819.16
8.1.130.0030.15717.86
8.1.120.0030.17017.54
8.1.110.0030.16717.48
8.1.100.0000.17017.46
8.1.90.0030.16217.37
8.1.80.0030.16017.49
8.1.70.0030.16417.48
8.1.60.0070.18717.59
8.1.50.0070.18717.61
8.1.40.0030.19417.44
8.1.30.0000.19517.62
8.1.20.0030.19117.63
8.1.10.0000.19417.57
8.1.00.0030.23917.50
8.0.300.0070.16018.77
8.0.290.0100.17116.75
8.0.280.0070.17318.40
8.0.270.0030.17317.21
8.0.260.0030.19417.28
8.0.250.0000.17716.95
8.0.240.0000.17717.02
8.0.230.0030.17717.04
8.0.220.0030.17716.88
8.0.210.0030.17216.88
8.0.200.0000.21117.02
8.0.190.0000.19816.89
8.0.180.0070.19017.00
8.0.170.0030.20317.00
8.0.160.0000.20017.01
8.0.150.0000.19816.88
8.0.140.0100.18816.82
8.0.130.0030.19213.32
8.0.120.0100.19316.79
8.0.110.0070.18916.83
8.0.100.0000.19916.97
8.0.90.0000.19916.77
8.0.80.0100.26616.91
8.0.70.0070.19216.87
8.0.60.0030.19516.94
8.0.50.0000.20116.76
8.0.30.0140.33716.97
8.0.20.0180.29717.40
8.0.10.0030.19317.05
8.0.00.0100.38516.80
7.4.330.0030.17115.03
7.4.320.0030.17916.63
7.4.300.0070.18316.52
7.4.290.0030.19516.66
7.4.280.0070.19416.63
7.4.270.0070.19416.46
7.4.260.0070.19316.51
7.4.250.0070.19216.48
7.4.240.0000.19916.60
7.4.230.0000.20016.57
7.4.220.0070.29916.64
7.4.210.0030.29116.64
7.4.200.0000.20016.45
7.4.160.0160.24516.47
7.4.150.0070.44417.40
7.4.140.0100.27317.86
7.4.130.0090.30916.38
7.4.120.0160.25516.60
7.4.110.0130.45416.43
7.4.100.0180.30516.47
7.4.90.0030.31616.40
7.4.80.0100.27216.55
7.4.70.0130.25916.65
7.4.60.0130.25816.35
7.4.50.0030.16716.52
7.4.40.0100.28216.68
7.4.30.0060.28616.49
7.4.00.0000.31814.71
7.3.330.0030.20213.34
7.3.320.0030.20813.42
7.3.310.0000.22416.29
7.3.300.0030.20916.25
7.3.290.0070.19816.40
7.3.280.0120.36316.40
7.3.270.0090.30017.40
7.3.260.0070.26316.41
7.3.250.0110.29416.51
7.3.240.0340.37116.39
7.3.230.0100.48316.57
7.3.210.0160.32616.59
7.3.200.0100.31119.39
7.3.190.0060.36716.62
7.3.180.0100.26016.34
7.3.170.0100.28316.67
7.3.160.0100.27416.50
7.3.10.0000.33516.29
7.3.00.0130.34816.18
7.2.330.0070.31716.79
7.2.320.0130.29716.81
7.2.310.0100.41116.61
7.2.300.0100.30516.82
7.2.290.0130.30016.86
7.2.130.0100.36316.69
7.2.120.0100.38716.77
7.2.110.0130.34716.63
7.2.100.0000.37716.22
7.2.90.0130.35016.72
7.2.80.0070.35116.58
7.2.70.0170.37416.51
7.2.60.0080.26416.86
7.2.50.0070.36616.69
7.2.40.0170.36516.40
7.2.30.0120.37816.74
7.2.20.0070.36916.46
7.2.10.0130.34816.52
7.2.00.0100.34718.01
7.1.250.0000.47015.25
7.1.200.0070.20915.79
7.1.100.0000.20818.11
7.1.70.0030.19817.30
7.1.60.0070.25419.46
7.1.50.0100.25416.79
7.1.00.0100.37022.44
7.0.200.0100.19914.91
7.0.140.0070.34022.10
7.0.60.0070.30019.96
7.0.50.0030.31018.00
7.0.40.0030.27320.26
7.0.30.0170.25020.08
7.0.20.0200.28320.23
7.0.10.0070.23020.12
7.0.00.0030.24320.22
5.6.280.0070.89321.03
5.6.210.0200.82720.48
5.6.200.0100.83718.17
5.6.190.0170.79020.55
5.6.180.0470.85020.34
5.6.170.0400.85320.47
5.6.160.0200.82320.50
5.6.150.0000.79018.18
5.6.140.0030.80718.18
5.6.130.0030.89318.27
5.6.120.0100.84321.12
5.6.110.0000.79021.09
5.6.100.0000.79021.12
5.6.90.0130.82321.14
5.6.80.0830.81320.45
5.5.350.0270.99720.31
5.5.340.0030.97717.97
5.5.330.0130.96320.40
5.5.320.0000.96320.27
5.5.310.0230.96020.33
5.5.300.0100.96317.95
5.5.290.0130.96017.99
5.5.280.0070.91320.94
5.5.270.0030.97720.86
5.5.260.0070.97720.80
5.5.250.0030.97020.72
5.5.240.0031.01020.16
5.4.450.0200.94719.48
5.4.440.0330.92719.30
5.4.430.0231.10019.30
5.4.420.0230.97019.19
5.4.410.0131.12319.25
5.4.400.0231.35719.09
5.4.390.0170.92019.22
5.4.380.0200.87319.26
5.4.370.0200.89719.31
5.4.360.0200.90719.06
5.4.350.0231.09318.85
5.4.340.0230.94719.08
5.4.320.0230.94719.16
5.4.310.0230.96319.11
5.4.300.0231.18318.86
5.4.290.0270.95318.99
5.4.280.0170.89019.22
5.4.270.1700.91019.13
5.4.260.0231.29019.30
5.4.250.0300.95318.84
5.4.240.0300.94719.08
5.4.230.0300.94318.99
5.4.220.0170.98019.05
5.4.210.0271.23319.13
5.4.200.0271.01719.13
5.4.190.0230.95719.14
5.4.180.0170.91019.12
5.4.170.0230.95719.30
5.4.160.0230.95319.21
5.4.150.0231.17018.82
5.4.140.0170.89316.41
5.4.130.0230.85716.39
5.4.120.0230.91016.42
5.4.110.0230.88716.45
5.4.100.0200.96316.32
5.4.90.0230.98716.39
5.4.80.0270.94316.48
5.4.70.0230.92316.59
5.4.60.0200.87016.34
5.4.50.0170.92016.33
5.4.40.0100.88316.37
5.4.30.0271.00016.50
5.4.20.0300.94016.55
5.4.10.0300.90716.53
5.4.00.0170.86315.87
5.3.290.0230.04314.66
5.3.280.0200.04314.52
5.3.270.0230.05014.71
5.3.260.0170.03714.69
5.3.250.0170.04714.63
5.3.240.0230.04714.60
5.3.230.0230.03014.82
5.3.220.0200.03314.54
5.3.210.0170.04014.54
5.3.200.0270.06314.72
5.3.190.0330.06314.53
5.3.180.0200.03714.57
5.3.170.0270.07014.46
5.3.160.0230.04714.58
5.3.150.0230.07314.79
5.3.140.0300.03714.52
5.3.130.0170.07714.63
5.3.120.0230.04714.66
5.3.110.0230.05314.46
5.3.100.0130.04014.26
5.3.90.0270.07013.92
5.3.80.0200.03713.91
5.3.70.0200.07713.93
5.3.60.0300.04013.92
5.3.50.0200.04714.05
5.3.40.0200.05013.87
5.3.30.0170.03714.02
5.3.20.0230.03313.69
5.3.10.0200.04013.56
5.3.00.0300.06313.57
5.2.170.0170.03011.28
5.2.160.0270.05311.28
5.2.150.0100.03311.30
5.2.140.0170.03011.28
5.2.130.0130.03311.28
5.2.120.0270.05311.28
5.2.110.0200.03711.28
5.2.100.0200.03711.28
5.2.90.0230.02711.28
5.2.80.0170.03011.28
5.2.70.0200.03011.28
5.2.60.0130.03311.28
5.2.50.0270.05311.28
5.2.40.0230.02711.28
5.2.30.0200.06011.28
5.2.20.0130.04011.28
5.2.10.0270.04711.28
5.2.00.0200.04711.28
5.1.60.0170.04311.28
5.1.50.0170.03011.28
5.1.40.0170.03711.28
5.1.30.0230.04711.28
5.1.20.0230.03711.28
5.1.10.0200.05311.28
5.1.00.0170.02711.28
5.0.50.0070.04711.28
5.0.40.0130.02311.28
5.0.30.0070.04711.28
5.0.20.0070.03711.28
5.0.10.0170.03011.28
5.0.00.0170.04311.28
4.4.90.0070.01711.28
4.4.80.0100.03311.28
4.4.70.0070.03011.28
4.4.60.0100.03311.28
4.4.50.0130.02711.28
4.4.40.0130.02711.28
4.4.30.0130.03011.28
4.4.20.0070.01711.28
4.4.10.0070.01711.28
4.4.00.0100.05311.28
4.3.110.0130.03011.28
4.3.100.0130.02311.28
4.3.90.0130.01011.28
4.3.80.0100.04711.28
4.3.70.0170.03011.28
4.3.60.0070.01711.28
4.3.50.0100.01311.28
4.3.40.0070.02711.28
4.3.30.0030.03311.28
4.3.20.0070.01711.28
4.3.10.0030.02311.28
4.3.00.0070.03711.28

preferences:
51.57 ms | 401 KiB | 5 Q