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'])) { $drupalSettings = mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE); } $a = mergeDeepArray(array($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', ), ); 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.01716.75
8.3.50.0090.01922.03
8.3.40.0040.01818.89
8.3.30.0070.01418.96
8.3.20.0040.00720.39
8.3.10.0090.00321.90
8.3.00.0100.00720.88
8.2.180.0170.01316.63
8.2.170.0120.00922.96
8.2.160.0030.01722.08
8.2.150.0060.00624.18
8.2.140.0060.00624.66
8.2.130.0030.00926.16
8.2.120.0090.00319.66
8.2.110.0130.02721.99
8.2.100.0100.01017.63
8.2.90.0080.00619.20
8.2.80.0070.00717.97
8.2.70.0090.00617.63
8.2.60.0000.01418.05
8.2.50.0000.01418.07
8.2.40.0040.01118.12
8.2.30.0000.01418.02
8.2.20.0070.00717.65
8.2.10.0000.01418.20
8.2.00.0000.01417.71
8.1.280.0100.01725.92
8.1.270.0030.01020.69
8.1.260.0080.00426.35
8.1.250.0040.00828.09
8.1.240.0070.01023.82
8.1.230.0030.01419.04
8.1.220.0000.01417.74
8.1.210.0040.01118.77
8.1.200.0030.01417.23
8.1.190.0040.01117.36
8.1.180.0000.01418.10
8.1.170.0060.00818.70
8.1.160.0000.01322.01
8.1.150.0060.00918.79
8.1.140.0070.01017.47
8.1.130.0000.01317.79
8.1.120.0000.01417.48
8.1.110.0000.01517.48
8.1.100.0030.01017.41
8.1.90.0030.01017.45
8.1.80.0030.01017.51
8.1.70.0000.01317.47
8.1.60.0060.00917.60
8.1.50.0040.01117.59
8.1.40.0060.00917.44
8.1.30.0070.01017.64
8.1.20.0000.01517.64
8.1.10.0060.00917.56
8.1.00.0070.01317.55
8.0.300.0000.01318.77
8.0.290.0000.01516.63
8.0.280.0030.01118.46
8.0.270.0000.01417.34
8.0.260.0000.01517.16
8.0.250.0070.00717.01
8.0.240.0090.00916.95
8.0.230.0080.00516.96
8.0.220.0000.01416.91
8.0.210.0030.01016.89
8.0.200.0030.01016.87
8.0.190.0000.01516.93
8.0.180.0000.01516.84
8.0.170.0040.01216.94
8.0.160.0060.00916.97
8.0.150.0060.00916.75
8.0.140.0000.01516.86
8.0.130.0030.01013.35
8.0.120.0000.01516.89
8.0.110.0000.01716.82
8.0.100.0070.00716.75
8.0.90.0090.00616.97
8.0.80.0130.02616.92
8.0.70.0030.01216.98
8.0.60.0000.01516.90
8.0.50.0060.00916.91
8.0.30.0070.03016.93
8.0.20.0100.02017.40
8.0.10.0000.01517.03
8.0.00.0120.01516.86
7.4.330.0030.01015.13
7.4.320.0000.01416.50
7.4.300.0000.01416.56
7.4.290.0070.00716.60
7.4.280.0060.01016.62
7.4.270.0040.01116.54
7.4.260.0060.00916.48
7.4.250.0040.01216.49
7.4.240.0000.01416.52
7.4.230.0000.01516.52
7.4.220.0070.02416.68
7.4.210.0080.02216.62
7.4.200.0030.01116.41
7.4.160.0070.03016.46
7.4.150.0100.01917.40
7.4.140.0120.01617.86
7.4.130.0110.02216.66
7.4.120.0080.02316.39
7.4.110.0120.01516.54
7.4.100.0130.01616.59
7.4.90.0100.01916.44
7.4.80.0000.03316.40
7.4.70.0150.02116.54
7.4.60.0130.01316.41
7.4.50.0040.00816.49
7.4.40.0130.01316.51
7.4.30.0060.02416.36
7.4.00.0110.02115.02
7.3.330.0040.01113.42
7.3.320.0060.01313.42
7.3.310.0000.01716.25
7.3.300.0040.01116.41
7.3.290.0070.01016.44
7.3.280.0110.01516.35
7.3.270.0030.02417.40
7.3.260.0120.01616.33
7.3.250.0110.01716.43
7.3.240.0060.03516.38
7.3.230.0090.02016.56
7.3.210.0100.02016.70
7.3.200.0100.03119.39
7.3.190.0120.01516.37
7.3.180.0100.01716.45
7.3.170.0080.02316.39
7.3.160.0100.01716.43
7.3.120.0090.02214.93
7.3.110.0070.02114.84
7.3.100.0030.02214.90
7.3.90.0030.02014.88
7.3.80.0030.02514.94
7.3.70.0000.02414.89
7.3.60.0030.02315.03
7.3.50.0070.01614.82
7.3.40.0090.01814.64
7.3.30.0110.01514.65
7.3.20.0060.02216.73
7.3.10.0030.02116.63
7.3.00.0070.02116.54
7.2.330.0090.02116.53
7.2.320.0090.01816.89
7.2.310.0130.03216.89
7.2.300.0090.02216.81
7.2.290.0070.02216.58
7.2.250.0090.02115.38
7.2.240.0100.02915.33
7.2.230.0100.02015.26
7.2.220.0030.02715.02
7.2.210.0040.02514.90
7.2.200.0000.02714.98
7.2.190.0100.02015.19
7.2.180.0040.02215.19
7.2.170.0040.02914.85
7.2.00.0030.02419.44
7.1.330.0130.02215.88
7.1.320.0070.02615.81
7.1.310.0070.02615.88
7.1.300.0000.02515.61
7.1.290.0060.02315.82
7.1.280.0070.02015.97
7.1.270.0030.02315.73
7.1.260.0030.02815.84
7.1.100.0000.02218.23
7.1.70.0030.02617.25
7.1.60.0060.02619.46
7.1.50.0070.02716.92
7.1.00.0000.09722.54
7.0.200.0090.00915.12
7.0.140.0000.04722.07
7.0.100.0070.09719.96
7.0.90.0100.08719.95
7.0.80.0070.09319.86
7.0.70.0170.08019.94
7.0.60.0430.09719.85
7.0.50.0200.05020.32
7.0.40.0070.09320.09
7.0.30.0070.08720.04
7.0.20.0100.09720.12
7.0.10.0100.09020.07
7.0.00.0070.09319.99
5.6.280.0070.12321.13
5.6.250.0000.13320.55
5.6.240.0230.08720.66
5.6.230.0070.13020.53
5.6.220.0070.12720.66
5.6.210.0030.12720.63
5.6.200.0070.13021.07
5.6.190.0030.13720.92
5.6.180.0070.12020.91
5.6.170.0030.13020.97
5.6.160.0030.12020.90
5.6.150.0130.10021.01
5.6.140.0070.10021.06
5.6.130.0130.12320.95
5.6.120.0070.13321.04
5.6.110.0130.09320.97
5.6.100.0030.11321.12
5.6.90.0030.07320.89
5.6.80.0130.10320.39
5.6.70.0100.12320.45
5.6.60.0130.09720.41
5.6.50.0030.07020.28
5.6.40.0100.11720.33
5.6.30.0300.07020.34
5.6.20.0130.12720.42
5.6.10.0070.12320.36
5.6.00.0100.09720.37
5.5.380.0030.09720.46
5.5.370.0030.12320.36
5.5.360.0030.10720.37
5.5.350.0030.13320.41
5.5.340.0130.11020.89
5.5.330.0170.12320.80
5.5.320.0100.13720.83
5.5.310.0100.07320.89
5.5.300.0170.10720.72
5.5.290.0130.10720.76
5.5.280.0030.13720.86
5.5.270.0100.13020.88
5.5.260.0070.13020.88
5.5.250.0100.11320.53
5.5.240.0070.11720.15
5.5.230.0070.14020.21
5.5.220.0170.13020.11
5.5.210.0070.12020.22
5.5.200.0030.13320.18
5.5.190.0130.11720.14
5.5.180.0100.08320.21
5.5.160.0100.09020.18
5.5.150.0070.13720.04
5.5.140.0030.12019.95
5.5.130.0100.12720.14
5.5.120.0100.12020.14
5.5.110.0030.10319.99
5.5.100.0000.09720.06
5.5.90.0070.06720.02
5.5.80.0030.07320.02
5.5.70.0170.09720.02
5.5.60.0070.09719.93
5.5.50.0030.09020.12
5.5.40.0100.10320.07
5.5.30.0070.14320.01
5.5.20.0030.13720.11
5.5.10.0030.07719.94
5.5.00.0030.10019.94
5.4.450.0070.12019.42
5.4.440.0030.13719.45
5.4.430.0070.08719.35
5.4.420.0100.11319.27
5.4.410.0100.12019.40
5.4.400.0100.11319.23
5.4.390.0130.12018.88
5.4.380.0170.08319.07
5.4.370.0100.12319.05
5.4.360.0000.10318.85
5.4.350.0030.12318.90
5.4.340.0100.12019.06
5.4.320.0000.11019.12
5.4.310.0030.07718.95
5.4.300.0200.12719.04
5.4.290.0100.10318.94
5.4.280.0100.13319.11
5.4.270.0070.11019.20
5.4.260.0170.11719.03
5.4.250.0100.11719.02
5.4.240.0100.11319.02
5.4.230.0000.08318.87
5.4.220.0030.09718.90
5.4.210.0100.12719.02
5.4.200.0100.11319.08
5.4.190.0070.15719.02
5.4.180.0030.07318.89
5.4.170.0030.07319.17
5.4.160.0130.08719.16
5.4.150.0030.07319.23
5.4.140.0030.07316.43
5.4.130.0000.07316.33
5.4.120.0000.07316.41
5.4.110.0030.08716.48
5.4.100.0030.06016.52
5.4.90.0030.07316.56
5.4.80.0000.07316.47
5.4.70.0030.09316.43
5.4.60.0000.08316.30
5.4.50.0030.06716.47
5.4.40.0030.10716.35
5.4.30.0030.05716.41
5.4.20.0030.08016.36
5.4.10.0000.06016.41
5.4.00.0030.05715.80
5.3.290.0070.06014.73
5.3.280.0000.03714.69
5.3.270.0070.05714.67
5.3.260.0000.04014.63
5.3.250.0070.04014.63
5.3.240.0000.03314.61
5.3.230.0000.04014.65
5.3.220.0100.03014.56
5.3.210.0030.03314.54
5.3.200.0000.04014.55
5.3.190.0030.03314.66
5.3.180.0070.03314.63
5.3.170.0070.07014.50
5.3.160.0070.07014.71
5.3.150.0030.03314.63
5.3.140.0070.07014.56
5.3.130.0030.04314.58
5.3.120.0030.03714.47
5.3.110.0030.04014.58
5.3.100.0000.04014.07
5.3.90.0030.03714.14
5.3.80.0000.03714.16
5.3.70.0030.03314.13
5.3.60.0070.05013.93
5.3.50.0030.03714.02
5.3.40.0030.03014.02
5.3.30.0070.03013.88
5.3.20.0070.03313.73
5.3.10.0000.03713.75
5.3.00.0070.03313.66
5.2.170.0000.03711.16
5.2.160.0070.02711.04
5.2.150.0070.03011.01
5.2.140.0070.03311.04
5.2.130.0030.02710.97
5.2.120.0030.02711.04
5.2.110.0000.03011.24
5.2.100.0030.02711.15
5.2.90.0030.02311.12
5.2.80.0030.02710.96
5.2.70.0070.02711.16
5.2.60.0000.02711.17
5.2.50.0000.03310.94
5.2.40.0000.03010.86
5.2.30.0070.02311.09
5.2.20.0070.03311.03
5.2.10.0030.02710.87
5.2.00.0070.02010.78
5.1.60.0000.0279.89
5.1.50.0000.02710.09
5.1.40.0070.01710.09
5.1.30.0000.03010.40
5.1.20.0030.02010.30
5.1.10.0030.0239.92
5.1.00.0000.02710.16
5.0.50.0030.0178.41
5.0.40.0030.0208.54
5.0.30.0000.0308.08
5.0.20.0070.0138.32
5.0.10.0000.0208.27
5.0.00.0000.0338.16
4.4.90.0000.0177.16
4.4.80.0000.0137.16
4.4.70.0070.0107.16
4.4.60.0000.0177.16
4.4.50.0030.0137.16
4.4.40.0000.0237.16
4.4.30.0000.0137.16
4.4.20.0030.0137.16
4.4.10.0070.0107.16
4.4.00.0000.0207.16
4.3.110.0000.0177.16
4.3.100.0030.0137.16
4.3.90.0000.0177.16
4.3.80.0000.0237.16
4.3.70.0030.0107.16
4.3.60.0070.0107.16
4.3.50.0100.0077.16
4.3.40.0000.0407.16
4.3.30.0030.0237.16
4.3.20.0000.0277.16
4.3.10.0030.0237.16
4.3.00.0000.0277.16

preferences:
44.11 ms | 401 KiB | 5 Q