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(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.0030.02316.88
8.3.50.0090.01921.94
8.3.40.0000.02318.75
8.3.30.0100.01319.09
8.3.20.0030.00820.39
8.3.10.0060.00621.73
8.3.00.0050.00820.75
8.2.180.0060.01918.16
8.2.170.0040.01822.96
8.2.160.0040.01822.20
8.2.150.0000.01224.18
8.2.140.0060.00624.66
8.2.130.0000.01226.16
8.2.120.0060.00619.95
8.2.110.0070.01020.35
8.2.100.0070.01117.75
8.2.90.0030.01119.16
8.2.80.0030.01217.97
8.2.70.0000.01417.75
8.2.60.0040.01118.03
8.2.50.0090.00918.07
8.2.40.0000.01518.16
8.2.30.0000.01518.25
8.2.20.0000.01517.77
8.2.10.0040.01118.02
8.2.00.0070.00717.68
8.1.280.0100.01325.92
8.1.270.0000.01220.64
8.1.260.0060.00626.35
8.1.250.0040.00828.09
8.1.240.0040.01423.83
8.1.230.0080.00919.09
8.1.220.0000.01417.74
8.1.210.0000.01418.77
8.1.200.0000.01617.25
8.1.190.0000.01417.47
8.1.180.0000.01418.10
8.1.170.0040.01118.64
8.1.160.0040.00922.09
8.1.150.0030.01218.83
8.1.140.0060.00917.48
8.1.130.0070.00717.86
8.1.120.0000.01417.45
8.1.110.0030.01117.45
8.1.100.0050.00817.52
8.1.90.0000.01417.49
8.1.80.0000.01317.41
8.1.70.0030.01017.48
8.1.60.0030.01317.49
8.1.50.0030.01217.55
8.1.40.0030.01217.37
8.1.30.0030.01317.73
8.1.20.0030.01317.66
8.1.10.0030.01317.47
8.1.00.0030.01617.54
8.0.300.0030.01018.77
8.0.290.0060.00816.75
8.0.280.0000.01418.40
8.0.270.0000.01416.85
8.0.260.0000.01717.33
8.0.250.0060.00916.95
8.0.240.0100.01017.00
8.0.230.0000.01516.87
8.0.220.0030.01016.93
8.0.210.0090.00616.80
8.0.200.0030.01016.84
8.0.190.0000.01516.96
8.0.180.0040.01116.92
8.0.170.0030.01316.93
8.0.160.0090.00616.90
8.0.150.0030.01216.75
8.0.140.0030.01216.84
8.0.130.0080.00513.28
8.0.120.0000.01516.89
8.0.110.0040.01116.96
8.0.100.0000.01516.86
8.0.90.0000.01516.90
8.0.80.0070.02016.87
8.0.70.0000.01616.89
8.0.60.0000.01416.89
8.0.50.0000.01516.87
8.0.30.0140.02017.21
8.0.20.0150.01817.40
8.0.10.0060.00916.82
8.0.00.0100.02416.83
7.4.330.0030.00915.03
7.4.320.0030.01016.54
7.4.300.0030.01116.51
7.4.290.0070.00716.60
7.4.280.0040.01216.59
7.4.270.0030.01316.45
7.4.260.0030.01316.58
7.4.250.0030.01216.55
7.4.240.0010.01316.55
7.4.230.0030.01116.74
7.4.220.0180.02816.56
7.4.210.0060.02516.65
7.4.200.0060.00916.65
7.4.160.0030.03516.62
7.4.150.0120.02817.40
7.4.140.0080.02717.86
7.4.130.0060.02316.58
7.4.120.0090.01916.45
7.4.110.0030.02316.37
7.4.100.0110.02116.58
7.4.90.0150.02816.62
7.4.80.0030.03316.48
7.4.70.0160.01716.48
7.4.60.0090.01816.64
7.4.50.0040.00816.52
7.4.40.0070.02416.39
7.4.30.0200.01516.77
7.4.00.0070.02414.93
7.3.330.0070.01013.32
7.3.320.0080.01213.32
7.3.310.0000.01516.47
7.3.300.0030.01216.43
7.3.290.0000.01516.44
7.3.280.0050.02616.43
7.3.270.0160.01617.40
7.3.260.0120.01616.35
7.3.250.0100.01916.55
7.3.240.0050.00816.74
7.3.230.0030.02416.39
7.3.210.0030.02416.52
7.3.200.0160.02519.39
7.3.190.0150.01216.71
7.3.180.0140.01416.38
7.3.170.0100.02016.40
7.3.160.0060.02116.57
7.3.120.0000.03114.87
7.3.110.0050.02514.70
7.3.100.0060.01914.98
7.3.90.0100.02414.94
7.3.80.0000.02514.61
7.3.70.0000.02714.67
7.3.60.0060.01914.71
7.3.50.0120.01514.77
7.3.40.0030.02614.82
7.3.30.0030.02214.92
7.3.20.0070.02016.75
7.3.10.0040.02216.46
7.3.00.0060.01916.54
7.2.330.0060.02516.59
7.2.320.0090.01916.73
7.2.310.0160.01516.65
7.2.300.0120.02116.50
7.2.290.0110.03416.77
7.2.250.0100.02015.02
7.2.240.0000.03515.08
7.2.230.0000.03015.31
7.2.220.0000.02215.40
7.2.210.0060.02215.18
7.2.200.0000.02414.98
7.2.190.0070.02315.06
7.2.180.0040.02114.99
7.2.170.0030.02715.07
7.2.80.0040.01916.90
7.2.00.0070.01319.44
7.1.330.0100.02116.08
7.1.320.0060.02515.96
7.1.310.0070.02615.99
7.1.300.0070.02715.62
7.1.290.0000.03315.81
7.1.280.0030.02715.93
7.1.270.0000.02915.86
7.1.260.0030.02615.54
7.1.200.0060.01315.99
7.1.100.0030.02317.76
7.1.70.0000.01617.34
7.1.60.0120.00917.38
7.1.50.0100.02716.91
7.1.00.0070.09022.28
7.0.200.0100.02716.64
7.0.140.0030.04322.11
7.0.110.0130.07320.03
7.0.100.0130.04320.13
7.0.90.0100.05020.07
7.0.80.0030.05019.89
7.0.70.0030.05320.00
7.0.60.0070.05020.09
7.0.50.0000.04320.30
7.0.40.0000.05320.11
7.0.30.0130.04020.28
7.0.20.0000.08020.15
7.0.10.0130.04020.21
7.0.00.0000.07720.12
5.6.280.0100.12321.05
5.6.260.0070.07020.90
5.6.250.0100.09020.90
5.6.240.0000.07720.71
5.6.230.0000.08020.67
5.6.220.0030.08320.69
5.6.210.0030.09320.82
5.6.200.0000.06321.28
5.6.190.0070.07021.20
5.6.180.0070.06721.16
5.6.170.0000.11721.06
5.6.160.0070.07021.10
5.6.150.0070.07721.00
5.6.140.0000.08321.10
5.6.130.0000.07721.23
5.6.120.0030.09720.94
5.6.110.0070.07021.03
5.6.100.0130.08721.15
5.6.90.0100.07021.11
5.6.80.0000.10020.45
5.6.70.0070.11720.53
5.6.60.0030.10720.67
5.6.50.0070.11020.34
5.6.40.0030.08720.48
5.6.30.0130.12320.32
5.6.20.0100.10320.51
5.6.10.0170.11020.51
5.6.00.0100.12720.49
5.5.380.0100.06720.56
5.5.370.0000.07720.56
5.5.360.0030.07320.36
5.5.350.0030.07320.53
5.5.340.0070.07720.91
5.5.330.0070.07320.92
5.5.320.0000.09020.88
5.5.310.0070.07320.74
5.5.300.0070.07320.82
5.5.290.0030.07721.05
5.5.280.0070.07320.96
5.5.270.0000.08020.78
5.5.260.0070.08320.75
5.5.250.0070.07320.51
5.5.240.0000.12320.19
5.5.230.0070.14020.23
5.5.220.0030.09720.06
5.5.210.0100.12320.09
5.5.200.0200.11020.35
5.5.190.0100.12320.26
5.5.180.0070.12720.23
5.5.160.0130.12320.33
5.5.150.0130.09720.20
5.5.140.0170.12020.14
5.5.130.0070.11320.06
5.5.120.0130.11720.26
5.5.110.0070.12720.16
5.5.100.0000.12720.04
5.5.90.0070.12020.26
5.5.80.0070.12320.29
5.5.70.0070.12320.20
5.5.60.0100.11020.22
5.5.50.0070.12320.05
5.5.40.0070.11720.02
5.5.30.0030.12720.23
5.5.20.0030.12020.20
5.5.10.0100.12020.19
5.5.00.0070.12020.14
5.4.450.0030.07719.52
5.4.440.0030.07319.66
5.4.430.0100.06719.63
5.4.420.0070.07019.64
5.4.410.0130.11319.20
5.4.400.0130.10718.96
5.4.390.0030.12319.01
5.4.380.0100.13319.34
5.4.370.0030.12719.23
5.4.360.0070.11718.97
5.4.350.0200.11019.14
5.4.340.0030.08319.22
5.4.320.0000.12719.18
5.4.310.0000.09019.02
5.4.300.0030.12718.95
5.4.290.0070.11319.24
5.4.280.0100.11719.02
5.4.270.0030.12019.01
5.4.260.0030.13319.18
5.4.250.0030.11019.18
5.4.240.0270.06319.23
5.4.230.0130.11719.13
5.4.220.0130.11719.14
5.4.210.0100.11719.17
5.4.200.0030.12319.02
5.4.190.0000.08719.08
5.4.180.0000.13319.17
5.4.170.0100.11719.33
5.4.160.0130.10319.01
5.4.150.0100.12019.00
5.4.140.0070.11316.58
5.4.130.0130.11316.52
5.4.120.0070.12016.44
5.4.110.0030.08316.63
5.4.100.0100.08016.52
5.4.90.0100.11016.70
5.4.80.0100.11316.40
5.4.70.0130.07716.60
5.4.60.0100.11716.54
5.4.50.0100.11016.54
5.4.40.0070.12016.57
5.4.30.0070.11716.52
5.4.20.0070.09716.39
5.4.10.0070.09316.45
5.4.00.0100.11715.80
5.3.290.0070.07714.68
5.3.280.0070.07314.46
5.3.270.0070.07314.64
5.3.260.0100.07014.61
5.3.250.0100.07014.84
5.3.240.0070.05014.64
5.3.230.0030.07714.83
5.3.220.0170.06314.56
5.3.210.0030.06314.55
5.3.200.0070.07014.71
5.3.190.0130.07314.70
5.3.180.0100.04014.43
5.3.170.0100.06314.71
5.3.160.0130.06314.56
5.3.150.0030.08014.42
5.3.140.0070.07314.59
5.3.130.0000.07714.56
5.3.120.0000.08014.69
5.3.110.0100.07014.41
5.3.100.0100.05714.18
5.3.90.0030.07314.11
5.3.80.0070.07014.02
5.3.70.0030.07714.11
5.3.60.0130.06314.04
5.3.50.0170.06313.95
5.3.40.0130.06013.97
5.3.30.0070.07013.99
5.3.20.0030.07313.84
5.3.10.0070.06713.73
5.3.00.0030.07313.65
5.2.170.0030.03712.09
5.2.160.0000.06712.09
5.2.150.0100.05712.09
5.2.140.0000.04012.09
5.2.130.0070.06012.09
5.2.120.0030.06012.09
5.2.110.0070.03712.09
5.2.100.0000.06712.09
5.2.90.0000.05012.09
5.2.80.0130.04312.09
5.2.70.0070.06012.09
5.2.60.0030.07012.09
5.2.50.0070.06012.09
5.2.40.0000.05712.09
5.2.30.0070.06012.09
5.2.20.0000.05712.09
5.2.10.0030.06012.09
5.2.00.0030.05712.09
5.1.60.0030.05012.09
5.1.50.0030.05712.09
5.1.40.0070.05012.09
5.1.30.0070.05712.09
5.1.20.0130.04712.09
5.1.10.0000.06012.09
5.1.00.0000.05712.09
5.0.50.0130.03312.09
5.0.40.0030.04312.09
5.0.30.0030.06312.09
5.0.20.0070.04012.09
5.0.10.0030.04312.09
5.0.00.0030.06312.09
4.4.90.0000.03712.09
4.4.80.0000.03712.09
4.4.70.0070.03012.09
4.4.60.0000.03712.09
4.4.50.0030.03312.09
4.4.40.0030.05012.09
4.4.30.0070.03012.09
4.4.20.0070.03012.09
4.4.10.0030.02312.09
4.4.00.0070.05012.09
4.3.110.0030.03312.09
4.3.100.0000.02712.09
4.3.90.0070.03012.09
4.3.80.0030.05012.09
4.3.70.0030.03712.09
4.3.60.0100.02712.09
4.3.50.0000.03712.09
4.3.40.0070.04712.09
4.3.30.0030.03312.09
4.3.20.0030.02312.09
4.3.10.0000.02712.09
4.3.00.0030.03312.09

preferences:
67.04 ms | 401 KiB | 5 Q