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', ), ); 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.70.0060.01616.63
8.3.60.0130.01316.63
8.3.50.0070.02022.05
8.3.40.0100.01318.71
8.3.30.0100.01719.18
8.3.20.0040.00820.38
8.3.10.0080.00421.87
8.3.00.0070.00719.20
8.2.180.0100.02318.54
8.2.170.0120.00922.96
8.2.160.0100.01722.16
8.2.150.0040.00824.18
8.2.140.0040.00824.66
8.2.130.0040.00826.16
8.2.120.0080.00419.77
8.2.110.0030.01519.27
8.2.100.0070.01017.78
8.2.90.0030.01117.84
8.2.80.0060.00918.14
8.2.70.0070.00717.75
8.2.60.0030.01217.75
8.2.50.0040.01117.75
8.2.40.0040.01119.65
8.2.30.0000.01418.19
8.2.20.0080.00617.85
8.2.10.0060.00918.13
8.2.00.0040.01117.82
8.1.280.0070.02025.92
8.1.270.0080.00420.73
8.1.260.0080.00326.35
8.1.250.0030.00928.09
8.1.240.0030.01422.45
8.1.230.0060.01220.97
8.1.220.0080.00817.76
8.1.210.0040.01118.97
8.1.200.0000.01517.13
8.1.190.0000.01517.35
8.1.180.0070.00718.10
8.1.170.0040.01117.62
8.1.160.0070.00721.95
8.1.150.0030.01018.82
8.1.140.0070.00719.13
8.1.130.0000.01317.72
8.1.120.0000.01517.46
8.1.110.0040.01117.43
8.1.100.0030.01017.48
8.1.90.0000.01417.47
8.1.80.0070.00717.38
8.1.70.0000.01517.47
8.1.60.0030.01317.52
8.1.50.0030.01317.55
8.1.40.0040.01417.51
8.1.30.0030.01317.67
8.1.20.0060.00917.65
8.1.10.0030.01217.60
8.1.00.0030.01717.54
8.0.300.0040.01119.90
8.0.290.0030.01216.63
8.0.280.0030.01018.47
8.0.270.0030.01017.22
8.0.260.0030.01017.27
8.0.250.0000.01316.94
8.0.240.0060.01316.86
8.0.230.0070.00716.99
8.0.220.0030.01016.89
8.0.210.0040.01016.96
8.0.200.0030.01016.97
8.0.190.0030.01216.88
8.0.180.0040.01116.96
8.0.170.0040.01216.80
8.0.160.0030.01216.83
8.0.150.0060.00916.96
8.0.140.0000.01516.77
8.0.130.0030.01013.34
8.0.120.0030.01216.80
8.0.110.0040.01116.88
8.0.100.0000.01416.95
8.0.90.0040.01116.77
8.0.80.0000.02516.96
8.0.70.0070.00716.82
8.0.60.0000.01516.77
8.0.50.0060.00916.79
8.0.30.0130.03017.01
8.0.20.0130.01517.40
8.0.10.0030.01216.93
8.0.00.0100.02316.93
7.4.330.0000.01315.05
7.4.320.0060.00616.58
7.4.300.0030.01016.51
7.4.290.0030.01216.68
7.4.280.0000.01616.66
7.4.270.0000.01416.65
7.4.260.0090.00616.59
7.4.250.0060.00916.39
7.4.240.0030.01216.51
7.4.230.0000.01416.52
7.4.220.0170.01416.52
7.4.210.0080.01916.71
7.4.200.0030.01216.62
7.4.160.0060.01916.52
7.4.150.0180.02517.40
7.4.140.0080.02417.86
7.4.130.0070.02416.43
7.4.120.0070.02116.50
7.4.110.0160.02516.54
7.4.100.0090.03116.43
7.4.90.0130.01716.69
7.4.80.0040.02416.48
7.4.70.0170.02416.55
7.4.60.0070.02416.62
7.4.50.0030.00616.42
7.4.40.0090.01816.56
7.4.30.0140.01716.52
7.4.10.0100.02716.64
7.4.00.0070.02415.83
7.3.330.0000.01613.15
7.3.320.0110.01113.18
7.3.310.0040.01116.29
7.3.300.0040.01116.43
7.3.290.0000.01616.36
7.3.280.0080.01816.39
7.3.270.0130.01717.40
7.3.260.0090.01916.75
7.3.250.0070.01916.40
7.3.240.0070.02316.39
7.3.230.0100.03116.63
7.3.210.0080.02016.66
7.3.200.0100.02119.39
7.3.190.0130.01616.30
7.3.180.0100.02716.32
7.3.170.0030.03216.58
7.3.160.0090.01916.37
7.3.130.0130.02216.38
7.3.120.0030.03316.45
7.3.110.0100.02016.25
7.3.100.0030.03416.34
7.3.90.0100.02616.31
7.3.80.0100.02016.39
7.3.70.0130.01616.40
7.3.60.0100.02016.35
7.3.50.0090.01816.35
7.3.40.0100.01716.45
7.3.30.0030.02616.32
7.3.20.0000.02518.14
7.3.10.0030.02318.23
7.3.00.0100.01718.26
7.2.330.0030.02716.78
7.2.320.0070.02416.73
7.2.310.0130.01916.79
7.2.300.0140.03116.79
7.2.290.0160.02616.48
7.2.260.0060.02916.46
7.2.250.0130.02716.70
7.2.240.0070.02316.59
7.2.230.0140.02716.58
7.2.220.0030.03716.61
7.2.210.0060.02316.79
7.2.200.0060.02516.53
7.2.190.0060.02616.73
7.2.180.0100.01916.76
7.2.170.0030.03016.54
7.2.160.0040.02616.61
7.2.150.0030.02318.57
7.2.140.0070.02518.51
7.2.130.0070.03218.41
7.2.120.0070.02418.64
7.2.110.0030.02418.25
7.2.100.0070.02018.24
7.2.90.0070.02318.46
7.2.80.0100.01418.25
7.2.70.0030.01918.42
7.2.60.0070.02618.43
7.2.50.0070.02718.54
7.2.40.0070.01718.51
7.2.30.0000.02718.41
7.2.20.0130.01618.53
7.2.10.0040.01818.34
7.2.00.0030.01818.89
7.1.330.0070.03717.36
7.1.320.0030.03017.62
7.1.310.0130.02917.33
7.1.300.0030.03017.41
7.1.290.0060.02617.32
7.1.280.0070.02717.46
7.1.270.0000.03217.55
7.1.260.0090.02517.25
7.1.250.0100.03217.36
7.1.240.0030.02417.35
7.1.230.0030.02717.29
7.1.220.0090.01817.41
7.1.210.0070.02617.39
7.1.200.0030.02417.39
7.1.190.0090.02117.39
7.1.180.0030.03217.29
7.1.170.0000.03717.45
7.1.160.0000.02917.38
7.1.150.0060.02617.32
7.1.140.0030.02517.51
7.1.130.0060.02217.40
7.1.120.0070.02017.30
7.1.110.0000.03017.41
7.1.100.0060.01917.63
7.1.90.0070.03317.47
7.1.80.0030.03017.42
7.1.70.0020.02317.28
7.1.60.0070.02718.35
7.1.50.0050.02717.07
7.1.40.0040.02917.41
7.1.30.0030.02517.59
7.1.20.0030.02717.44
7.1.10.0000.02817.30
7.1.00.0060.05919.90
7.0.330.0070.03016.94
7.0.320.0040.02916.95
7.0.310.0000.03017.12
7.0.300.0070.02717.20
7.0.290.0000.03517.10
7.0.280.0070.02817.09
7.0.270.0070.02617.09
7.0.260.0030.02617.00
7.0.250.0030.02717.20
7.0.240.0030.03217.28
7.0.230.0040.02916.95
7.0.220.0030.02917.04
7.0.210.0070.02417.12
7.0.200.0100.02216.07
7.0.190.0000.03517.09
7.0.180.0030.02617.15
7.0.170.0090.01917.10
7.0.160.0030.02517.14
7.0.150.0070.02617.13
7.0.140.0050.03719.53
7.0.130.0070.02516.91
7.0.120.0030.02416.88
7.0.110.0000.03817.09
7.0.100.0030.02816.96
7.0.90.0130.02617.03
7.0.80.0030.03217.13
7.0.70.0030.03719.38
7.0.60.0050.04119.44
7.0.50.0030.04719.64
7.0.40.0050.05217.53
7.0.30.0120.04717.56
7.0.20.0060.06317.45
7.0.10.0070.06017.46
7.0.00.0050.06517.52
5.6.400.0030.06516.16
5.6.390.0030.06216.13
5.6.380.0070.06816.03
5.6.370.0030.06416.12
5.6.360.0100.06016.13
5.6.350.0100.06016.19
5.6.340.0060.06216.21
5.6.330.0030.06216.07
5.6.320.0070.05815.91
5.6.310.0000.06716.16
5.6.300.0030.06615.84
5.6.290.0100.05816.12
5.6.280.0080.08918.44
5.6.270.0070.06116.23
5.6.260.0000.06416.00
5.6.250.0030.06516.13
5.6.240.0070.07015.85
5.6.230.0000.06815.79
5.6.220.0050.06518.36
5.6.210.0070.09518.43
5.6.200.0020.10018.56
5.6.190.0050.09818.53
5.6.180.0130.08718.42
5.6.170.0070.09118.48
5.6.160.0020.07918.39
5.6.150.0150.10318.57
5.6.140.0050.09718.44
5.6.130.0100.08618.63
5.6.120.0050.10118.62
5.6.110.0080.09818.41
5.6.100.0070.10018.65
5.6.90.0030.10418.44
5.6.80.0090.09018.25
5.6.70.0080.09618.14
5.6.60.0050.09818.18
5.6.50.0070.10418.05
5.6.40.0070.09518.26
5.6.30.0050.09218.06
5.6.20.0050.08618.28
5.6.10.0070.09618.10
5.6.00.0020.09418.22
5.5.380.0070.06016.09
5.5.370.0030.06415.71
5.5.360.0100.07618.32
5.5.350.0050.06818.30
5.5.340.0000.09918.36
5.5.330.0050.07518.29
5.5.320.0080.10518.37
5.5.310.0020.07818.37
5.5.300.0050.09518.43
5.5.290.0080.09918.49
5.5.280.0030.10518.32
5.5.270.0070.09518.26
5.5.260.0030.08218.26
5.5.250.0080.10318.35
5.5.240.0070.08018.12
5.5.230.0080.09218.09
5.5.220.0030.10218.12
5.5.210.0080.09518.03
5.5.200.0050.09517.97
5.5.190.0030.10518.00
5.5.180.0030.10518.09
5.5.170.0130.06915.69
5.5.160.0050.08217.99
5.5.150.0050.09017.98
5.5.140.0030.09318.04
5.5.130.0110.09118.03
5.5.120.0030.08818.05
5.5.110.0070.09418.00
5.5.100.0120.09817.97
5.5.90.0030.10717.95
5.5.80.0070.09818.00
5.5.70.0020.09617.91
5.5.60.0050.09518.06
5.5.50.0050.10017.95
5.5.40.0070.09917.92
5.5.30.0100.09617.88
5.5.20.0030.09918.03
5.5.10.0030.09918.09
5.5.00.0030.08217.85
5.4.450.0030.10416.11
5.4.440.0030.08216.26
5.4.430.0030.10216.08
5.4.420.0050.10016.21
5.4.410.0030.09515.95
5.4.400.0050.09815.95
5.4.390.0020.08715.95
5.4.380.0080.08615.97
5.4.370.0020.09815.90
5.4.360.0030.10715.88
5.4.350.0030.10416.09
5.4.340.0050.08915.97
5.4.330.0070.06312.74
5.4.320.0070.08016.06
5.4.310.0050.09515.94
5.4.300.0080.09115.75
5.4.290.0150.08715.88
5.4.280.0080.09515.89
5.4.270.0030.09015.98
5.4.260.0080.09116.03
5.4.250.0020.10415.90
5.4.240.0050.06815.98
5.4.230.0020.09315.86
5.4.220.0030.09015.96
5.4.210.0020.10215.93
5.4.200.0070.09615.93
5.4.190.0070.10615.81
5.4.180.0020.10615.79
5.4.170.0070.09415.93
5.4.160.0030.09315.91
5.4.150.0020.10015.98
5.4.140.0030.10514.61
5.4.130.0030.09814.71
5.4.120.0080.09414.56
5.4.110.0080.09914.63
5.4.100.0020.09714.56
5.4.90.0050.08214.57
5.4.80.0070.08314.62
5.4.70.0080.09114.56
5.4.60.0030.10014.58
5.4.50.0070.09114.54
5.4.40.0050.09214.53
5.4.30.0050.09614.67
5.4.20.0050.10814.64
5.4.10.0050.08214.46
5.4.00.0030.09914.26
5.3.290.0030.07714.61
5.3.280.0030.06314.52
5.3.270.0000.07714.66
5.3.260.0000.05314.59
5.3.250.0000.05714.70
5.3.240.0000.04714.70
5.3.230.0000.07014.63
5.3.220.0100.07314.62
5.3.210.0100.07714.54
5.3.200.0070.07714.52
5.3.190.0030.07314.58
5.3.180.0100.06714.60
5.3.170.0030.08014.62
5.3.160.0070.05314.63
5.3.150.0030.04014.63
5.3.140.0030.04314.66
5.3.130.0030.04714.62
5.3.120.0030.04014.67
5.3.110.0070.07714.50
5.3.100.0100.03314.00
5.3.90.0000.07314.00
5.3.80.0000.08014.11
5.3.70.0030.04713.95
5.3.60.0030.05313.89
5.3.50.0000.07013.93
5.3.40.0030.07713.87
5.3.30.0000.07013.91
5.3.20.0030.07013.74
5.3.10.0000.06713.66
5.3.00.0070.05013.62
5.2.170.0000.04011.20
5.2.160.0030.05711.19
5.2.150.0000.04311.15
5.2.140.0100.05711.14
5.2.130.0030.06011.17
5.2.120.0000.06311.16
5.2.110.0100.05311.00
5.2.100.0030.04011.01
5.2.90.0000.06011.13
5.2.80.0000.06311.12
5.2.70.0100.05710.98
5.2.60.0000.06011.03
5.2.50.0000.06010.88
5.2.40.0000.06010.98
5.2.30.0030.06011.03
5.2.20.0000.05311.07
5.2.10.0130.04710.92
5.2.00.0030.05710.81
5.1.60.0070.03310.81
5.1.50.0000.04310.81
5.1.40.0070.02710.81
5.1.30.0000.03010.81
5.1.20.0030.06010.81
5.1.10.0000.05310.81
5.1.00.0000.05710.81
5.0.50.0000.04310.81
5.0.40.0030.04710.81
5.0.30.0000.06710.81
5.0.20.0000.03710.81
5.0.10.0000.04310.81
5.0.00.0070.05010.81
4.4.90.0000.02710.81
4.4.80.0000.03710.81
4.4.70.0000.03710.81
4.4.60.0000.03710.81
4.4.50.0030.03010.81
4.4.40.0000.05310.81
4.4.30.0000.02310.81
4.4.20.0030.02710.81
4.4.10.0030.03710.81
4.4.00.0000.05710.81
4.3.110.0000.03710.81
4.3.100.0100.02310.81
4.3.90.0030.03310.81
4.3.80.0000.05710.81
4.3.70.0000.03310.81
4.3.60.0000.02710.81
4.3.50.0030.01710.81
4.3.40.0070.04310.81
4.3.30.0000.03710.81
4.3.20.0000.03010.81
4.3.10.0030.03010.81
4.3.00.0000.03710.81

preferences:
98.42 ms | 401 KiB | 5 Q