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($b['drupalSettings'])) { $temp = mergeDeepArray([$a['drupalSettings'], $b['drupalSettings']], TRUE); } $a = mergeDeepArray([$a, $b]); if (isset($temp)) { $a['drupalSettings'] = $temp; } 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 <= 10000; $i++) { $a['#attached'] = array( 'library' => array( 'core/drupal', 'core/drupalSettings', ), ); $b['#attached'] = array( 'library' => array( 'core/jquery', ), ); mergeAttachmentsOld($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.0160.01316.75
8.3.50.0080.01921.99
8.3.40.0090.01218.55
8.3.30.0100.01718.97
8.3.20.0060.00620.38
8.3.10.0000.01221.73
8.3.00.0060.00620.81
8.2.180.0100.02418.41
8.2.170.0090.01222.96
8.2.160.0070.01422.13
8.2.150.0060.00624.18
8.2.140.0040.00824.66
8.2.130.0030.00826.16
8.2.120.0090.00319.64
8.2.110.0060.01222.17
8.2.100.0090.00917.63
8.2.90.0000.01419.36
8.2.80.0070.00717.97
8.2.70.0000.01617.50
8.2.60.0090.00618.05
8.2.50.0000.01718.07
8.2.40.0000.01418.22
8.2.30.0000.01518.16
8.2.20.0000.01417.88
8.2.10.0000.01518.02
8.2.00.0000.01517.68
8.1.280.0030.01825.92
8.1.270.0030.00920.72
8.1.260.0040.00726.35
8.1.250.0060.00628.09
8.1.240.0030.01423.97
8.1.230.0120.00619.10
8.1.220.0030.01217.89
8.1.210.0030.01318.77
8.1.200.0030.01317.22
8.1.190.0070.00717.22
8.1.180.0000.01418.10
8.1.170.0000.01518.59
8.1.160.0070.00722.12
8.1.150.0000.01418.85
8.1.140.0000.01519.14
8.1.130.0030.01017.85
8.1.120.0030.01017.55
8.1.110.0030.01217.45
8.1.100.0070.00717.45
8.1.90.0080.00617.41
8.1.80.0070.00717.45
8.1.70.0070.00717.38
8.1.60.0000.01617.68
8.1.50.0060.01017.54
8.1.40.0000.01717.52
8.1.30.0040.01217.59
8.1.20.0040.01117.59
8.1.10.0000.01617.54
8.1.00.0070.01417.47
8.0.300.0030.01018.77
8.0.290.0040.01116.75
8.0.280.0070.00718.53
8.0.270.0030.01117.21
8.0.260.0000.01417.32
8.0.250.0070.00716.95
8.0.240.0000.01916.97
8.0.230.0030.01016.88
8.0.220.0000.01416.92
8.0.210.0040.01116.93
8.0.200.0060.00816.99
8.0.190.0040.01116.88
8.0.180.0040.01116.93
8.0.170.0060.01016.93
8.0.160.0040.01116.96
8.0.150.0040.01216.81
8.0.140.0040.01516.83
8.0.130.0000.01313.31
8.0.120.0060.01016.77
8.0.110.0060.00916.91
8.0.100.0080.00816.81
8.0.90.0030.01216.89
8.0.80.0130.01316.87
8.0.70.0040.01116.94
8.0.60.0040.01116.84
8.0.50.0040.01116.87
8.0.30.0100.02117.12
8.0.20.0130.01617.40
8.0.10.0080.00816.93
8.0.00.0110.01616.77
7.4.330.0000.01315.08
7.4.320.0030.01016.50
7.4.300.0030.01016.52
7.4.290.0060.00916.39
7.4.280.0060.01016.57
7.4.270.0030.01216.54
7.4.260.0030.01216.59
7.4.250.0000.01516.63
7.4.240.0030.01116.56
7.4.230.0000.01516.71
7.4.220.0100.02616.53
7.4.210.0070.01916.62
7.4.200.0030.01216.43
7.4.160.0060.01916.45
7.4.150.0070.02117.40
7.4.140.0120.01617.86
7.4.130.0080.02916.57
7.4.120.0090.01916.37
7.4.110.0180.01516.58
7.4.100.0120.01816.40
7.4.90.0100.01916.64
7.4.80.0060.02716.60
7.4.70.0090.03016.64
7.4.60.0070.02116.39
7.4.50.0000.02016.41
7.4.40.0120.01516.50
7.4.30.0100.02016.56
7.4.00.0130.01714.88
7.3.330.0060.01013.31
7.3.320.0100.01013.39
7.3.310.0040.01116.45
7.3.300.0040.01116.36
7.3.290.0090.00616.39
7.3.280.0070.02116.38
7.3.270.0100.02017.40
7.3.260.0170.01316.66
7.3.250.0070.02216.47
7.3.240.0180.02116.63
7.3.230.0130.02616.66
7.3.210.0040.02716.45
7.3.200.0120.03019.39
7.3.190.0100.02416.41
7.3.180.0070.02116.52
7.3.170.0070.02516.31
7.3.160.0130.01616.43
7.2.330.0090.02216.93
7.2.320.0130.02016.52
7.2.310.0130.02816.79
7.2.300.0030.02816.77
7.2.290.0100.02016.78
7.2.00.0060.01619.47
7.1.100.0000.01918.12
7.1.70.0030.01217.09
7.1.60.0100.02419.46
7.1.50.0160.02916.72
7.1.00.0070.09022.30
7.0.200.1330.01715.04
7.0.140.0070.07721.95
7.0.100.0100.04720.09
7.0.90.0130.05019.99
7.0.80.0170.09020.02
7.0.70.0030.04719.95
7.0.60.0000.06320.00
7.0.50.0070.09720.37
7.0.40.0100.07320.09
7.0.30.0230.07719.96
7.0.20.0070.08320.05
7.0.10.0070.09320.02
7.0.00.0030.09020.04
5.6.280.0070.12721.00
5.6.250.0000.08020.68
5.6.240.0070.07020.63
5.6.230.0070.09320.52
5.6.220.0070.07020.58
5.6.210.0070.12320.67
5.6.200.0070.12020.96
5.6.190.0100.09721.05
5.6.180.0070.07021.07
5.6.170.0070.09321.09
5.6.160.0130.11320.95
5.6.150.0100.07021.07
5.6.140.0070.08021.14
5.6.130.0130.11321.12
5.6.120.0070.11021.09
5.6.110.0030.08321.11
5.6.100.0130.12721.05
5.6.90.0100.12021.02
5.6.80.0100.12320.50
5.6.70.0300.10720.35
5.6.60.0200.12320.43
5.6.50.0030.06320.54
5.6.40.0070.08020.39
5.6.30.0200.11020.31
5.6.20.0070.12320.36
5.6.10.0070.12320.45
5.6.00.0000.06720.41
5.5.380.0030.08020.58
5.5.370.0070.08320.51
5.5.360.0070.14020.41
5.5.350.0070.10320.37
5.5.340.0170.12720.81
5.5.330.0100.07020.88
5.5.320.0000.11320.66
5.5.310.0130.10720.81
5.5.300.0200.12320.77
5.5.290.0130.08720.87
5.5.280.0070.13720.79
5.5.270.0070.08020.91
5.5.260.0170.10720.90
5.5.250.0070.07020.72
5.5.240.0000.13720.17
5.5.230.0070.13720.16
5.5.220.0030.08320.25
5.5.210.0000.07320.23
5.5.200.0030.13320.25
5.5.190.0030.11720.29
5.5.180.0130.12720.26
5.5.160.0000.14020.23
5.5.150.0030.12020.22
5.5.140.0130.10720.09
5.5.130.0030.12720.16
5.5.120.0130.12720.19
5.5.110.0030.12020.15
5.5.100.0200.07720.13
5.5.90.0130.12020.08
5.5.80.0070.09719.96
5.5.70.0130.11320.10
5.5.60.0170.10320.07
5.5.50.0030.12020.04
5.5.40.0070.11320.06
5.5.30.0030.12020.07
5.5.20.0130.13020.06
5.5.10.0000.08720.05
5.5.00.0070.08020.05
5.4.450.0130.10319.24
5.4.440.0070.12019.23
5.4.430.0100.08019.36
5.4.420.0030.12719.17
5.4.410.0130.11319.23
5.4.400.0070.07718.90
5.4.390.0070.11719.14
5.4.380.0100.11319.05
5.4.370.0070.12718.84
5.4.360.0030.06718.95
5.4.350.0030.09718.86
5.4.340.0130.07719.16
5.4.320.0100.07018.85
5.4.310.0070.11719.09
5.4.300.0130.08318.92
5.4.290.0030.12018.90
5.4.280.0000.08319.21
5.4.270.0030.09319.16
5.4.260.0030.11019.04
5.4.250.0100.12718.94
5.4.240.0000.09018.84
5.4.230.0100.12019.11
5.4.220.0070.11019.11
5.4.210.0100.06018.87
5.4.200.0070.06318.91
5.4.190.0100.06719.08
5.4.180.0000.13018.81
5.4.170.0030.08019.09
5.4.160.0130.11319.01
5.4.150.0030.09019.03
5.4.140.0070.07316.39
5.4.130.0030.10716.54
5.4.120.0070.10016.46
5.4.110.0070.10316.48
5.4.100.0130.12316.45
5.4.90.0170.12016.45
5.4.80.0270.06716.46
5.4.70.0070.07316.37
5.4.60.0070.10016.45
5.4.50.0030.08016.44
5.4.40.0030.08016.46
5.4.30.0100.08316.31
5.4.20.0130.07716.44
5.4.10.0070.08716.46
5.4.00.0100.11315.79
5.3.290.0070.06315.74
5.3.280.0000.08015.74
5.3.270.0070.04315.74
5.3.260.0070.07715.74
5.3.250.0100.05715.74
5.3.240.0070.06315.74
5.3.230.0030.08015.74
5.3.220.0000.04715.74
5.3.210.0170.06315.74
5.3.200.0000.04715.74
5.3.190.0100.04015.74
5.3.180.0130.07715.74
5.3.170.0030.05715.74
5.3.160.0100.06015.74
5.3.150.0000.05315.74
5.3.140.0100.07715.74
5.3.130.0070.04015.74
5.3.120.0130.05315.74
5.3.110.0130.06715.74
5.3.100.0030.07715.74
5.3.90.0030.07315.74
5.3.80.0030.07015.74
5.3.70.0100.07015.74
5.3.60.0030.03715.74
5.3.50.0030.04015.74
5.3.40.0000.04315.74
5.3.30.0030.04715.74
5.3.20.0130.05715.74
5.3.10.0100.05015.74
5.3.00.0170.05315.74
5.2.170.0000.06715.74
5.2.160.0130.03315.74
5.2.150.0070.06015.74
5.2.140.0030.06015.74
5.2.130.0070.06015.74
5.2.120.0070.04315.74
5.2.110.0030.06015.74
5.2.100.0030.06715.74
5.2.90.0100.05715.74
5.2.80.0030.03015.74
5.2.70.0030.03015.74
5.2.60.0070.06315.74
5.2.50.0030.03315.74
5.2.40.0000.03315.74
5.2.30.0000.06315.74
5.2.20.0070.05015.74
5.2.10.0030.05015.74
5.2.00.0100.05715.74
5.1.60.0030.04715.74
5.1.50.0030.05015.74
5.1.40.0070.05715.74
5.1.30.0030.04315.74
5.1.20.0130.04315.74
5.1.10.0030.05715.74
5.1.00.0030.03315.74
5.0.50.0070.03715.74
5.0.40.0000.02315.74
5.0.30.0030.05315.74
5.0.20.0070.01315.74
5.0.10.0030.02015.74
5.0.00.0030.03015.74
4.4.90.0030.04315.74
4.4.80.0030.03315.74
4.4.70.0030.01715.74
4.4.60.0000.01715.74
4.4.50.0000.01715.74
4.4.40.0000.02715.74
4.4.30.0000.01715.74
4.4.20.0000.02715.74
4.4.10.0070.01715.74
4.4.00.0000.05715.74
4.3.110.0000.03315.74
4.3.100.0000.01715.74
4.3.90.0000.01715.74
4.3.80.0030.02315.74
4.3.70.0000.01315.74
4.3.60.0030.01315.74
4.3.50.0000.01715.74
4.3.40.0000.02315.74
4.3.30.0000.01715.74
4.3.20.0000.01715.74
4.3.10.0000.01315.74
4.3.00.0000.01715.74

preferences:
60.53 ms | 401 KiB | 5 Q