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_recursive($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.0030.09416.63
8.3.50.0120.09822.18
8.3.40.0100.08218.87
8.3.30.0100.08619.21
8.3.20.0030.04620.34
8.3.10.0000.04921.65
8.3.00.0100.05520.90
8.2.180.0100.10117.99
8.2.170.0070.08622.96
8.2.160.0070.08422.26
8.2.150.0100.04024.18
8.2.140.0040.04624.66
8.2.130.0000.05026.16
8.2.120.0000.05020.75
8.2.110.0070.09021.07
8.2.100.0070.07517.50
8.2.90.0030.07519.27
8.2.80.0070.07317.97
8.2.70.0030.07717.63
8.2.60.0060.07418.05
8.2.50.0030.07718.07
8.2.40.0070.07018.34
8.2.30.0030.07418.14
8.2.20.0030.07717.77
8.2.10.0100.06818.02
8.2.00.0000.07917.79
8.1.280.0100.09425.92
8.1.270.0100.04618.89
8.1.260.0030.04526.35
8.1.250.0070.04428.09
8.1.240.0070.08919.21
8.1.230.0030.07019.15
8.1.220.0070.06917.79
8.1.210.0100.06818.77
8.1.200.0110.09217.38
8.1.190.0100.06917.36
8.1.180.0070.07018.10
8.1.170.0030.07320.43
8.1.160.0070.06522.04
8.1.150.0000.07518.90
8.1.140.0000.07717.38
8.1.130.0030.06717.89
8.1.120.0000.07717.48
8.1.110.0000.07617.51
8.1.100.0000.07517.39
8.1.90.0030.07317.48
8.1.80.0030.07317.46
8.1.70.0000.07717.48
8.1.60.0070.08517.49
8.1.50.0030.08717.43
8.1.40.0070.08517.48
8.1.30.0030.08917.70
8.1.20.0070.08517.55
8.1.10.0000.09117.57
8.1.00.0000.09117.52
8.0.300.0030.07218.77
8.0.290.0070.07316.75
8.0.280.0070.07018.39
8.0.270.0030.07417.19
8.0.260.0030.07517.12
8.0.250.0030.07516.98
8.0.240.0030.07717.00
8.0.230.0030.07516.96
8.0.220.0030.07516.92
8.0.210.0000.07816.95
8.0.200.0070.08716.98
8.0.190.0070.08816.84
8.0.180.0070.08916.94
8.0.170.0030.09216.92
8.0.160.0030.09116.81
8.0.150.0030.09216.84
8.0.140.0060.08816.77
8.0.130.0030.09513.32
8.0.120.0000.09516.88
8.0.110.0000.09216.89
8.0.100.0030.09016.91
8.0.90.0030.09016.71
8.0.80.0160.13616.84
8.0.70.0030.09116.78
8.0.60.0060.08716.69
8.0.50.0100.09016.94
8.0.30.0130.15517.10
8.0.20.0130.15617.40
8.0.10.0000.09416.82
8.0.00.0100.11916.88
7.4.330.0060.07215.14
7.4.320.0030.07816.52
7.4.300.0030.07616.53
7.4.290.0070.08716.57
7.4.280.0070.09016.64
7.4.270.0030.09216.45
7.4.260.0000.09516.40
7.4.250.0030.09216.42
7.4.240.0050.08916.60
7.4.230.0000.09416.42
7.4.220.0130.13316.64
7.4.210.0080.11616.48
7.4.200.0000.09416.44
7.4.160.0030.12516.55
7.4.150.0160.11617.40
7.4.140.0130.19317.86
7.4.130.0110.11616.51
7.4.120.0130.12216.50
7.4.110.0100.20916.42
7.4.100.0130.20116.57
7.4.90.0120.11716.46
7.4.80.0130.16716.64
7.4.70.0100.11716.53
7.4.60.0070.14816.72
7.4.50.0030.06716.54
7.4.40.0060.13016.52
7.4.30.0200.17916.62
7.4.10.0060.18116.33
7.4.00.0110.15415.77
7.3.330.0030.09113.20
7.3.320.0030.11513.46
7.3.310.0070.09016.29
7.3.300.0030.09216.25
7.3.290.0130.08716.25
7.3.280.0090.15516.36
7.3.270.0060.12317.40
7.3.260.0070.13516.73
7.3.250.0080.14616.41
7.3.240.0070.12316.43
7.3.230.0060.20616.39
7.3.210.0100.13716.63
7.3.200.0100.21719.39
7.3.190.0130.11716.63
7.3.180.0100.16016.35
7.3.170.0030.20916.61
7.3.160.0100.14016.35
7.3.130.0000.17416.38
7.3.120.0100.17216.42
7.3.110.0100.12616.36
7.3.100.0070.18116.34
7.3.90.0070.15716.37
7.3.80.0070.14916.27
7.3.70.0070.18116.57
7.3.60.0100.17116.40
7.3.50.0030.14516.45
7.3.40.0100.18416.32
7.3.30.0030.18616.55
7.3.20.0000.14218.26
7.3.10.0030.14518.00
7.3.00.0070.14118.25
7.2.330.0100.16316.57
7.2.320.0160.12716.84
7.2.310.0130.15216.62
7.2.300.0130.12916.59
7.2.290.0130.19016.59
7.2.260.0070.16016.67
7.2.250.0070.19016.54
7.2.240.0100.16316.66
7.2.230.0000.18216.73
7.2.220.0030.17116.57
7.2.210.0100.16016.55
7.2.200.0000.17316.54
7.2.190.0070.14616.54
7.2.180.0030.16816.45
7.2.170.0070.21016.50
7.2.160.0070.19616.54
7.2.150.0100.17318.46
7.2.140.0070.14318.48
7.2.130.0030.21418.55
7.2.120.0030.19418.43
7.2.110.0070.18818.51
7.2.100.0070.16318.41
7.2.90.0070.16518.30
7.2.80.0070.18418.37
7.2.70.0100.14918.46
7.2.60.0020.15617.71
7.2.50.0100.14518.33
7.2.40.0000.18918.45
7.2.30.0030.16118.52
7.2.20.0030.15018.53
7.2.10.0070.21618.46
7.2.00.0000.15218.28
7.1.330.0100.18717.36
7.1.320.0030.21617.36
7.1.310.0030.20317.49
7.1.300.0070.17617.51
7.1.290.0070.17417.45
7.1.280.0000.25117.39
7.1.270.0130.18717.42
7.1.260.0070.18217.24
7.1.250.0130.22217.32
7.1.240.0000.19017.29
7.1.230.0000.20017.36
7.1.220.0070.24417.30
7.1.210.0030.18217.42
7.1.200.0030.14216.58
7.1.190.0000.25017.25
7.1.180.0000.19517.43
7.1.170.0030.21817.34
7.1.160.0100.17117.37
7.1.150.0070.22717.50
7.1.140.0070.18017.22
7.1.130.0000.24217.27
7.1.120.0070.20717.32
7.1.110.0030.24317.35
7.1.100.0070.22817.38
7.1.90.0030.16617.16
7.1.80.0100.17717.43
7.1.70.0300.15417.37
7.1.60.0080.16018.44
7.1.50.0070.16917.08
7.1.40.0030.19117.29
7.1.30.0030.18317.46
7.1.20.0000.19917.48
7.1.10.0030.18517.33
7.1.00.0050.20019.83
7.0.330.0030.26617.02
7.0.320.0030.23317.14
7.0.310.0030.20317.04
7.0.300.0030.21216.95
7.0.290.0030.27017.08
7.0.280.0070.23917.16
7.0.270.0030.18217.03
7.0.260.0000.20517.11
7.0.250.0070.21917.04
7.0.240.0070.21416.96
7.0.230.0070.25617.15
7.0.220.0070.25217.14
7.0.210.0000.20417.09
7.0.200.0070.16816.08
7.0.190.0000.27117.18
7.0.180.0000.23017.02
7.0.170.0000.20517.14
7.0.160.0100.19416.96
7.0.150.0030.21417.00
7.0.140.0030.22719.54
7.0.130.0130.22817.21
7.0.120.0070.23616.91
7.0.110.0100.24817.11
7.0.100.0030.27116.94
7.0.90.0000.25017.05
7.0.80.0100.26416.98
7.0.70.0100.23416.94
7.0.60.0030.20719.34
7.0.50.0050.18817.44
7.0.40.0050.19317.70
7.0.30.0170.16417.61
7.0.20.0120.19017.61
7.0.10.0030.16417.53
7.0.00.0100.20217.58
5.6.400.0100.65115.95
5.6.390.0100.72615.92
5.6.380.0070.58316.29
5.6.370.0000.69616.20
5.6.360.0070.70816.11
5.6.350.0070.69616.29
5.6.340.0070.61416.13
5.6.330.0000.73616.11
5.6.320.0030.64515.79
5.6.310.0030.77816.10
5.6.300.0030.72816.02
5.6.290.0000.64616.05
5.6.280.0000.65118.46
5.6.270.0120.72615.91
5.6.260.0030.59016.07
5.6.250.0000.63816.05
5.6.240.0070.67115.96
5.6.230.0070.62516.17
5.6.220.0070.56416.07
5.6.210.0300.52318.39
5.6.200.0050.51517.12
5.6.190.0070.47618.26
5.6.180.0300.50918.19
5.6.170.0170.51118.31
5.6.160.0100.54318.36
5.6.150.0080.61816.98
5.6.140.0050.55417.29
5.6.130.0030.54417.04
5.6.120.0050.59618.39
5.6.110.0080.50718.47
5.6.100.0050.54118.51
5.6.90.0080.50918.47
5.6.80.0150.50318.23
5.6.70.0070.57515.80
5.6.60.0000.70015.95
5.6.50.0070.77915.65
5.6.40.0070.61915.76
5.6.30.0030.74315.87
5.6.20.0030.65316.16
5.6.10.0070.58416.02
5.6.00.0030.71915.90
5.5.380.0130.61216.06
5.5.370.0020.60116.14
5.5.360.0120.63715.91
5.5.350.0230.68118.18
5.5.340.0070.66717.00
5.5.330.0080.59018.08
5.5.320.0130.55218.14
5.5.310.0200.49518.15
5.5.300.0110.53616.96
5.5.290.0060.62017.11
5.5.280.0130.57818.42
5.5.270.0050.63818.42
5.5.260.0110.60918.47
5.5.250.0080.58118.36
5.5.240.0120.64918.07
5.5.230.0200.85615.89
5.5.220.0070.76616.03
5.5.210.0210.82015.97
5.5.200.0160.67115.82
5.5.190.0060.85815.89
5.5.180.0210.79315.87
5.5.170.0170.70215.95
5.5.160.0100.66715.86
5.5.150.0070.62615.79
5.5.140.0130.58715.74
5.5.130.0090.65415.99
5.5.120.0090.79715.90
5.5.110.0130.66016.05
5.5.100.0070.73115.76
5.5.90.0130.65815.95
5.5.80.0130.70715.96
5.5.70.0120.65115.92
5.5.60.0170.73915.67
5.5.50.0130.71715.65
5.5.40.0090.63815.76
5.5.30.0340.69015.80
5.5.20.0230.94815.82
5.5.10.0100.89315.90
5.5.00.0030.87116.00
5.4.450.1760.58716.13
5.4.440.0200.64116.07
5.4.430.1210.58516.10
5.4.420.1650.55616.13
5.4.410.1830.57016.10
5.4.400.1770.60815.79
5.4.390.1720.65315.87
5.4.380.1600.60515.85
5.4.370.1800.58515.95
5.4.360.1520.56115.95
5.4.350.1750.65915.82
5.4.340.1830.64915.97
5.4.330.0070.69812.88
5.4.320.1770.63215.89
5.4.310.1700.59515.80
5.4.300.1550.58015.87
5.4.290.1830.55115.93
5.4.280.1780.56715.78
5.4.270.1680.58815.81
5.4.260.1750.59316.07
5.4.250.1730.59815.87
5.4.240.1760.57615.84
5.4.230.1700.54516.00
5.4.220.1800.68415.88
5.4.210.1850.59116.03
5.4.200.1810.58115.96
5.4.190.1630.59015.97
5.4.180.2250.63715.85
5.4.170.0560.54715.91
5.4.160.1630.56815.98
5.4.150.1520.64615.80
5.4.140.1400.57214.69
5.4.130.1280.55214.69
5.4.120.1620.54314.63
5.4.110.1620.61914.67
5.4.100.1770.68514.63
5.4.90.1700.64714.44
5.4.80.1750.60614.45
5.4.70.1820.65214.61
5.4.60.1620.63414.73
5.4.50.1540.59714.65
5.4.40.1870.60314.50
5.4.30.1910.61014.63
5.4.20.1700.60114.51
5.4.10.1850.60814.54
5.4.00.1850.54614.45
5.3.290.3300.03714.77
5.3.280.3130.04014.52
5.3.270.2330.03314.60
5.3.260.1930.04014.70
5.3.250.2300.03714.52
5.3.240.2700.03314.52
5.3.230.2630.03714.69
5.3.220.3500.03014.49
5.3.210.3330.03714.66
5.3.200.3530.03014.60
5.3.190.3700.04014.49
5.3.180.3630.04014.43
5.3.170.3370.04314.59
5.3.160.3400.04014.55
5.3.150.3300.04014.55
5.3.140.3530.03014.68
5.3.130.3530.04014.55
5.3.120.2770.04014.53
5.3.110.3570.03714.47
5.3.100.3270.03713.95
5.3.90.3570.02713.94
5.3.80.3300.04013.94
5.3.70.3670.03014.11
5.3.60.3530.03314.10
5.3.50.3330.04013.87
5.3.40.2970.04713.88
5.3.30.3270.03713.95
5.3.20.3330.03313.82
5.3.10.3030.03013.57
5.3.00.3300.03013.70
5.2.170.2230.03011.07
5.2.160.3030.03311.25
5.2.150.2770.03011.09
5.2.140.2930.03311.17
5.2.130.2870.02711.24
5.2.120.2700.03011.20
5.2.110.2730.03011.12
5.2.100.2700.02711.03
5.2.90.3430.02711.02
5.2.80.2770.03011.32
5.2.70.2900.02711.01
5.2.60.2700.02711.29
5.2.50.3000.03011.01
5.2.40.2200.02310.94
5.2.30.2270.02710.91
5.2.20.2300.03310.89
5.2.10.2600.02710.88
5.2.00.2170.02710.64
5.1.60.2170.0239.99
5.1.50.2270.02310.14
5.1.40.2230.02710.11
5.1.30.2730.02010.28
5.1.20.2430.02710.29
5.1.10.2230.02710.14
5.1.00.2230.03310.32
5.0.50.1100.0238.49
5.0.40.1130.0208.52
5.0.30.1170.0238.18
5.0.20.1470.0178.46
5.0.10.1230.0238.25
5.0.00.1130.0338.17
4.4.90.1100.0137.64
4.4.80.1100.0177.64
4.4.70.1200.0236.22
4.4.60.1200.0176.22
4.4.50.1230.0136.22
4.4.40.1130.0236.22
4.4.30.1200.0176.22
4.4.20.1100.0176.22
4.4.10.1170.0136.22
4.4.00.1170.0276.22
4.3.110.1100.0176.22
4.3.100.1130.0136.22
4.3.90.1100.0206.22
4.3.80.1170.0206.22
4.3.70.1200.0136.22
4.3.60.1130.0136.22
4.3.50.1070.0176.22
4.3.40.1030.0276.22
4.3.30.0600.0176.22
4.3.20.0600.0136.22
4.3.10.0530.0176.22
4.3.00.0600.0176.22

preferences:
58.83 ms | 401 KiB | 5 Q