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 = array_merge($a, $b); if (isset($drupalSettings)) { // Save the custom merge for the drupalSettings. $a['drupalSettings'] = $drupalSettings; } return $a; } 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.0130.08616.63
8.3.50.0100.07318.06
8.3.40.0070.07418.66
8.3.30.0070.08218.78
8.3.20.0040.03920.29
8.3.10.0070.03721.90
8.3.00.0000.04619.11
8.2.180.0100.08825.92
8.2.170.0100.06918.92
8.2.160.0200.07622.96
8.2.150.0030.03825.66
8.2.140.0030.03924.66
8.2.130.0030.03926.16
8.2.120.0100.03519.85
8.2.110.0100.08122.20
8.2.100.0100.06017.60
8.2.90.0030.06419.30
8.2.80.0030.06317.97
8.2.70.0100.06217.63
8.2.60.0030.07618.05
8.2.50.0030.06518.07
8.2.40.0030.06318.28
8.2.30.0000.06818.02
8.2.20.0030.06417.77
8.2.10.0000.06618.00
8.2.00.0030.06417.83
8.1.280.0100.09025.92
8.1.270.0100.03224.66
8.1.260.0030.03726.35
8.1.250.0000.04328.09
8.1.240.0030.08123.88
8.1.230.0100.05519.16
8.1.220.0070.05817.74
8.1.210.0070.05918.77
8.1.200.0100.05817.35
8.1.190.0030.06417.35
8.1.180.0070.05918.10
8.1.170.0030.06018.73
8.1.160.0000.06222.08
8.1.150.0000.06418.90
8.1.140.0000.06517.36
8.1.130.0000.06017.89
8.1.120.0070.06017.38
8.1.110.0030.06117.38
8.1.100.0030.06217.51
8.1.90.0000.06817.40
8.1.80.0070.05817.51
8.1.70.0030.06317.48
8.1.60.0070.07417.60
8.1.50.0000.07917.51
8.1.40.0030.07517.46
8.1.30.0070.07617.58
8.1.20.0000.07917.64
8.1.10.0100.07117.57
8.1.00.0030.07617.50
8.0.300.0030.06118.77
8.0.290.0070.06216.63
8.0.280.0000.06718.46
8.0.270.0060.06217.20
8.0.260.0030.07017.21
8.0.250.0000.06916.91
8.0.240.0030.06616.91
8.0.230.0100.05816.90
8.0.220.0000.06916.80
8.0.210.0030.06516.74
8.0.200.0000.06816.94
8.0.190.0000.08316.95
8.0.180.0030.07816.91
8.0.170.0000.08216.97
8.0.160.0060.07516.95
8.0.150.0000.08116.82
8.0.140.0030.07716.77
8.0.130.0000.08113.38
8.0.120.0070.07516.81
8.0.110.0030.07816.93
8.0.100.0000.08016.93
8.0.90.0070.07416.91
8.0.80.0100.17316.89
8.0.70.0000.08316.80
8.0.60.0030.07816.89
8.0.50.0030.07716.97
8.0.30.0140.14116.96
8.0.20.0100.10417.40
8.0.10.0030.08117.09
8.0.00.0130.10616.73
7.4.330.0030.06515.09
7.4.320.0000.07116.67
7.4.300.0000.07216.61
7.4.290.0000.08216.42
7.4.280.0000.08316.60
7.4.270.0100.07416.45
7.4.260.0030.07916.47
7.4.250.0100.09116.57
7.4.240.0020.08016.60
7.4.230.0000.08116.45
7.4.220.0060.13016.59
7.4.210.0090.16316.68
7.4.200.0000.08216.52
7.4.160.0070.10216.48
7.4.150.0130.17217.40
7.4.140.0080.10717.86
7.4.130.0060.10616.51
7.4.120.0080.10916.59
7.4.110.0060.11216.48
7.4.100.0070.17216.72
7.4.90.0100.13016.52
7.4.80.0230.11116.46
7.4.70.0100.12016.52
7.4.60.0060.10216.37
7.4.50.0030.05516.27
7.4.40.0070.11916.38
7.4.30.0160.13716.47
7.4.00.0070.13015.13
7.3.330.0000.08213.21
7.3.320.0000.08913.32
7.3.310.0030.08016.39
7.3.300.0070.07616.35
7.3.290.0090.10916.39
7.3.280.0050.11616.37
7.3.270.0150.15017.40
7.3.260.0090.12616.43
7.3.250.0100.13216.58
7.3.240.0130.10516.66
7.3.230.0130.12316.43
7.3.210.0130.11416.39
7.3.200.0190.11419.39
7.3.190.0160.10716.59
7.3.180.0130.10816.36
7.3.170.0160.15216.45
7.3.160.0030.12416.52
7.3.10.0130.12816.66
7.3.00.0100.13716.23
7.2.330.0090.20316.78
7.2.320.0060.11616.55
7.2.310.0070.12616.51
7.2.300.0130.11116.71
7.2.290.0130.11016.68
7.2.130.0070.14316.94
7.2.120.0100.16016.64
7.2.110.0130.14716.71
7.2.100.0070.14616.63
7.2.90.0130.15216.91
7.2.80.0150.14516.44
7.2.70.0070.14316.88
7.2.60.0120.11116.72
7.2.50.0080.15116.62
7.2.40.0290.14616.68
7.2.30.0240.14416.42
7.2.20.0190.14016.44
7.2.10.0100.13916.49
7.2.00.0050.11818.19
7.1.250.0070.17415.71
7.1.200.0000.08415.77
7.1.100.0000.08518.09
7.1.70.0000.07617.29
7.1.60.0070.12819.46
7.1.50.0030.14116.72
7.1.00.0030.20322.51
7.0.200.0170.08615.04
7.0.140.0000.20021.99
7.0.60.0030.19319.99
7.0.50.0030.14317.88
7.0.40.0030.16720.07
7.0.30.0200.13020.27
7.0.20.0400.17020.19
7.0.10.0100.12020.24
7.0.00.0030.18320.33
5.6.280.0000.46721.11
5.6.210.0770.38020.48
5.6.200.0030.45018.15
5.6.190.0100.40720.49
5.6.180.0330.38320.55
5.6.170.0300.51020.54
5.6.160.0100.39720.52
5.6.150.0070.36318.14
5.6.140.0030.39718.27
5.6.130.0070.39718.20
5.6.120.0000.40021.06
5.6.110.0100.42321.15
5.6.100.0170.42020.99
5.6.90.0130.42321.11
5.6.80.0100.42320.38
5.5.350.0300.40720.45
5.5.340.0070.42717.98
5.5.330.0030.45320.28
5.5.320.0100.44020.34
5.5.310.0730.41720.19
5.5.300.0030.50017.95
5.5.290.0030.43318.07
5.5.280.0000.38720.88
5.5.270.0030.39320.90
5.5.260.0130.45020.89
5.5.250.0170.49720.59
5.5.240.0070.45020.16
5.4.450.0200.71319.63
5.4.440.1430.67019.47
5.4.430.0730.78019.19
5.4.420.0770.70019.21
5.4.410.0970.70319.34
5.4.400.0830.65318.87
5.4.390.0200.68718.49
5.4.380.0100.66018.71
5.4.370.0200.67718.62
5.4.360.0130.78718.79
5.4.350.0130.66718.71
5.4.340.0200.63318.45
5.4.320.0130.66318.45
5.4.310.0130.65318.60
5.4.300.0230.72718.74
5.4.290.0130.71018.69
5.4.280.0271.10718.66
5.4.270.0170.74718.79
5.4.260.0170.72318.70
5.4.250.0130.66718.48
5.4.240.0300.66018.77
5.4.230.0200.66718.45
5.4.220.0100.69018.69
5.4.210.0030.75718.78
5.4.200.0030.70016.64
5.4.190.0170.70718.71
5.4.180.0230.73018.84
5.4.170.0171.06018.56
5.4.160.0130.79318.44
5.4.150.0200.74318.46
5.4.140.0100.68316.47
5.4.130.0300.66316.23
5.4.120.0170.66316.28
5.4.110.0230.66016.19
5.4.100.0270.65316.23
5.4.90.0170.71716.30
5.4.80.0000.72016.35
5.4.70.0100.68716.46
5.4.60.0130.87716.13
5.4.50.0200.78316.29
5.4.40.0070.70316.28
5.4.30.0070.66716.29
5.4.20.0170.96316.42
5.4.10.0100.86016.23
5.4.00.0230.79715.74
5.3.290.0100.05714.71
5.3.280.0130.05314.66
5.3.270.0130.05714.66
5.3.260.0130.05314.66
5.3.250.0130.05714.62
5.3.240.0070.06014.66
5.3.230.0200.04714.59
5.3.220.0200.05714.76
5.3.210.0170.05014.71
5.3.200.0100.05314.68
5.3.190.0170.04714.58
5.3.180.0300.05714.57
5.3.170.0200.05014.74
5.3.160.0230.04714.74
5.3.150.0170.05714.79
5.3.140.0200.04714.61
5.3.130.0100.06014.72
5.3.120.0070.08314.68
5.3.110.0130.07714.57
5.3.100.0130.05314.16
5.3.90.0200.04314.19
5.3.80.0070.05714.14
5.3.70.0130.05014.09
5.3.60.0100.05314.23
5.3.50.0200.04314.07
5.3.40.0130.05014.07
5.3.30.0200.04013.93
5.3.20.0200.04013.82
5.3.10.0130.04713.66
5.3.00.0170.05013.65
5.2.170.0100.05311.21
5.2.160.0070.04711.16
5.2.150.0130.04311.38
5.2.140.0100.04311.14
5.2.130.0100.04711.26
5.2.120.0070.04311.18
5.2.110.0200.03011.17
5.2.100.0070.04311.14
5.2.90.0030.04711.13
5.2.80.0070.04311.32
5.2.70.0170.05311.23
5.2.60.0230.03711.11
5.2.50.0070.04711.26
5.2.40.0070.04011.23
5.2.30.0100.04011.20
5.2.20.0130.03710.97
5.2.10.0100.03710.98
5.2.00.0130.03710.86
5.1.60.0070.03310.04
5.1.50.0030.04010.06
5.1.40.0200.04010.01
5.1.30.0070.04010.54
5.1.20.0130.03310.49
5.1.10.0130.03310.16
5.1.00.0070.03710.12
5.0.50.0070.0338.61
5.0.40.0000.0408.54
5.0.30.0100.0408.29
5.0.20.0070.0278.42
5.0.10.0100.0278.40
5.0.00.0070.0438.31
4.4.90.0000.0276.05
4.4.80.0030.0235.96
4.4.70.0030.0235.94
4.4.60.0030.0235.95
4.4.50.0030.0235.97
4.4.40.0130.0275.89
4.4.30.0130.0136.00
4.4.20.0000.0275.96
4.4.10.0130.0205.95
4.4.00.0000.0405.98
4.3.110.0000.0305.86
4.3.100.0070.0205.82
4.3.90.0100.0205.93
4.3.80.0070.0305.86
4.3.70.0000.0275.86
4.3.60.0000.0275.91
4.3.50.0100.0175.86
4.3.40.0000.0405.80
4.3.30.0070.0205.24
4.3.20.0000.0305.24
4.3.10.0100.0175.24
4.3.00.0000.04014.42

preferences:
47.37 ms | 400 KiB | 5 Q