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', ), ); 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.0170.01318.27
8.3.50.0120.01621.96
8.3.40.0110.01118.70
8.3.30.0070.01419.23
8.3.20.0040.00720.39
8.3.10.0060.00621.85
8.3.00.0040.00820.90
8.2.180.0070.02116.88
8.2.170.0110.01122.96
8.2.160.0160.00919.50
8.2.150.0060.00624.18
8.2.140.0080.00424.66
8.2.130.0040.00826.16
8.2.120.0000.01219.95
8.2.110.0030.01422.25
8.2.100.0040.01517.63
8.2.90.0000.01419.21
8.2.80.0060.01017.97
8.2.70.0030.01217.75
8.2.60.0000.01417.93
8.2.50.0040.01518.07
8.2.40.0040.01118.22
8.2.30.0030.01118.02
8.2.20.0060.00917.73
8.2.10.0070.00718.09
8.2.00.0000.01417.84
8.1.280.0100.02125.92
8.1.270.0030.00920.64
8.1.260.0040.00726.35
8.1.250.0060.00628.09
8.1.240.0070.01023.79
8.1.230.0070.01019.23
8.1.220.0040.01117.75
8.1.210.0000.01518.77
8.1.200.0030.01417.35
8.1.190.0000.01417.35
8.1.180.0040.01118.10
8.1.170.0070.00718.66
8.1.160.0000.01322.05
8.1.150.0030.01118.83
8.1.140.0030.01217.54
8.1.130.0000.01317.75
8.1.120.0060.00817.47
8.1.110.0000.01417.38
8.1.100.0000.01417.43
8.1.90.0000.01417.52
8.1.80.0030.01017.43
8.1.70.0030.01017.38
8.1.60.0000.01617.59
8.1.50.0030.01317.57
8.1.40.0030.01217.44
8.1.30.0040.01217.64
8.1.20.0030.01217.70
8.1.10.0030.01217.58
8.1.00.0070.01317.41
8.0.300.0030.01018.77
8.0.290.0090.00616.75
8.0.280.0000.01418.46
8.0.270.0030.01017.34
8.0.260.0100.00717.21
8.0.250.0030.01016.92
8.0.240.0070.01417.02
8.0.230.0000.01416.96
8.0.220.0000.01416.94
8.0.210.0000.01416.89
8.0.200.0030.01016.95
8.0.190.0030.01216.88
8.0.180.0100.00617.00
8.0.170.0030.01416.94
8.0.160.0040.01116.94
8.0.150.0030.01216.82
8.0.140.0030.01216.80
8.0.130.0000.01313.37
8.0.120.0030.01316.77
8.0.110.0030.01316.92
8.0.100.0000.01616.90
8.0.90.0000.01516.79
8.0.80.0100.02916.89
8.0.70.0030.01316.89
8.0.60.0000.01516.79
8.0.50.0030.01216.93
8.0.30.0120.03017.28
8.0.20.0060.02317.40
8.0.10.0060.00916.91
8.0.00.0140.01416.85
7.4.330.0030.00915.10
7.4.320.0030.01116.52
7.4.300.0030.01216.52
7.4.290.0030.01216.63
7.4.280.0050.01416.48
7.4.270.0000.01516.64
7.4.260.0040.01116.44
7.4.250.0000.01516.57
7.4.240.0020.01316.60
7.4.230.0000.01516.36
7.4.220.0170.02816.73
7.4.210.0090.02216.67
7.4.200.0000.01416.50
7.4.160.0070.01816.75
7.4.150.0170.01717.40
7.4.140.0110.01917.86
7.4.130.0030.02416.54
7.4.120.0100.01816.55
7.4.110.0070.02116.50
7.4.100.0150.02516.60
7.4.90.0100.01816.65
7.4.80.0110.01816.33
7.4.70.0060.03316.36
7.4.60.0090.01816.57
7.4.50.0030.01716.72
7.4.40.0120.01516.43
7.4.30.0130.02516.66
7.4.00.0100.01715.00
7.3.330.0070.01113.21
7.3.320.0000.02113.31
7.3.310.0030.01216.25
7.3.300.0000.01416.38
7.3.290.0060.01116.43
7.3.280.0130.02116.35
7.3.270.0130.01617.40
7.3.260.0060.02216.37
7.3.250.0080.02216.60
7.3.240.0050.02416.49
7.3.230.0070.02516.39
7.3.210.0090.01916.46
7.3.200.0210.02219.39
7.3.190.0100.01716.44
7.3.180.0120.01616.38
7.3.170.0090.02216.64
7.3.160.0100.01716.32
7.2.330.0060.02416.50
7.2.320.0090.01916.88
7.2.310.0070.03816.48
7.2.300.0060.02516.88
7.2.290.0040.02516.71
7.2.00.0000.02219.48
7.1.100.0000.02417.96
7.1.70.0030.01317.06
7.1.60.0100.02919.46
7.1.50.0070.02716.61
7.1.00.0030.09322.44
7.0.200.0070.01714.89
7.0.140.0000.04722.00
7.0.60.0070.07320.05
7.0.50.0000.07317.87
7.0.40.0100.09020.30
7.0.30.0370.08720.16
7.0.20.0230.08720.33
7.0.10.0100.09320.05
7.0.00.0070.09720.10
5.6.280.0000.13321.16
5.6.210.0100.10320.76
5.6.200.0130.11718.17
5.6.190.0000.07720.77
5.6.180.0370.07720.58
5.6.170.0200.07020.52
5.6.160.0100.10720.71
5.6.150.0070.11718.19
5.6.140.0100.12018.18
5.6.130.0100.10018.27
5.6.120.0100.10720.91
5.6.110.0030.10020.90
5.6.100.0070.08020.95
5.6.90.0130.11020.99
5.6.80.0170.06720.34
5.5.350.0330.12020.40
5.5.340.0100.10317.97
5.5.330.0070.08020.25
5.5.320.0300.12020.20
5.5.310.0200.08320.20
5.5.300.0000.07717.98
5.5.290.0130.12717.95
5.5.280.0070.13320.89
5.5.270.0130.12720.87
5.5.260.0100.11720.88
5.5.250.0070.07720.52
5.5.240.0070.09020.36
5.4.450.0870.15319.48
5.4.440.0800.13019.47
5.4.430.0970.11719.38
5.4.420.0330.17319.66
5.4.410.0770.11319.43
5.4.400.0800.11719.29
5.4.390.0170.17018.75
5.4.380.0170.12718.74
5.4.370.0130.14318.73
5.4.360.0200.13718.81
5.4.350.0130.17718.79
5.4.340.0300.15718.74
5.4.320.0070.18018.81
5.4.310.0100.14018.78
5.4.300.0330.17018.71
5.4.290.0270.15318.80
5.4.280.0200.11318.77
5.4.270.0200.17318.46
5.4.260.0170.12318.45
5.4.250.0170.14318.57
5.4.240.0330.16318.70
5.4.230.0170.18018.77
5.4.220.0200.18018.59
5.4.210.0230.17318.45
5.4.200.0200.17716.61
5.4.190.0330.15318.73
5.4.180.0200.17318.50
5.4.170.0170.17318.84
5.4.160.0200.11718.82
5.4.150.0200.18018.45
5.4.140.0200.17716.25
5.4.130.0170.11716.28
5.4.120.0230.13716.29
5.4.110.0130.14316.26
5.4.100.0070.12316.44
5.4.90.0100.17716.48
5.4.80.0270.15716.32
5.4.70.0130.13016.30
5.4.60.0200.12016.15
5.4.50.0170.11716.31
5.4.40.0230.15016.46
5.4.30.0070.14316.29
5.4.20.0170.12716.27
5.4.10.0200.16716.39
5.4.00.0170.18315.89
5.3.290.0230.06714.82
5.3.280.0230.05014.73
5.3.270.0130.05714.64
5.3.260.0070.06014.63
5.3.250.0200.06014.77
5.3.240.0170.05314.66
5.3.230.0100.06014.72
5.3.220.0200.05014.61
5.3.210.0070.06314.74
5.3.200.0170.04714.63
5.3.190.0170.05314.59
5.3.180.0100.05714.70
5.3.170.0130.05714.73
5.3.160.0100.06314.74
5.3.150.0200.06014.70
5.3.140.0170.05314.68
5.3.130.0200.07014.66
5.3.120.0200.05014.59
5.3.110.0130.05714.72
5.3.100.0100.05314.10
5.3.90.0230.04014.04
5.3.80.0130.05014.09
5.3.70.0130.05314.10
5.3.60.0130.05014.00
5.3.50.0100.05314.00
5.3.40.0300.05313.94
5.3.30.0200.06013.98
5.3.20.0130.06713.82
5.3.10.0130.06013.70
5.3.00.0100.05713.72
5.2.170.0170.04011.21
5.2.160.0130.04711.15
5.2.150.0300.02711.20
5.2.140.0000.05711.36
5.2.130.0000.06311.21
5.2.120.0070.04311.31
5.2.110.0130.04011.13
5.2.100.0170.03711.21
5.2.90.0100.04311.21
5.2.80.0070.05311.23
5.2.70.0100.04311.21
5.2.60.0070.06011.05
5.2.50.0130.05011.13
5.2.40.0200.03311.00
5.2.30.0130.05011.01
5.2.20.0270.03011.09
5.2.10.0130.05010.91
5.2.00.0100.04710.76
5.1.60.0030.04710.13
5.1.50.0030.04010.04
5.1.40.0130.04310.00
5.1.30.0170.03310.38
5.1.20.0100.03710.39
5.1.10.0130.04710.12
5.1.00.0130.03710.26
5.0.50.0070.0308.60
5.0.40.0100.0308.52
5.0.30.0070.0478.25
5.0.20.0130.0208.19
5.0.10.0130.0238.38
5.0.00.0070.0538.29
4.4.90.0100.0275.96
4.4.80.0100.0276.02
4.4.70.0030.0235.93
4.4.60.0000.0275.90
4.4.50.0070.0205.92
4.4.40.0070.0435.92
4.4.30.0070.0205.97
4.4.20.0100.0276.00
4.4.10.0100.0276.06
4.4.00.0070.0436.05
4.3.110.0070.0305.84
4.3.100.0070.0275.91
4.3.90.0100.0275.80
4.3.80.0000.0475.84
4.3.70.0000.0305.79
4.3.60.0070.0275.89
4.3.50.0030.0305.85
4.3.40.0030.0375.87
4.3.30.0000.0274.58
4.3.20.0000.0274.67
4.3.10.0070.0204.57
4.3.00.0070.0237.09

preferences:
46.25 ms | 401 KiB | 5 Q