3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeAttachments(array $a, array $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(array $a, array $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(array $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 <= 1000; $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.0150.00316.75
8.3.50.0100.01021.98
8.3.40.0000.01519.02
8.3.30.0040.01118.84
8.3.20.0050.00320.29
8.3.10.0080.00021.94
8.3.00.0040.00719.03
8.2.180.0090.01318.09
8.2.170.0130.00322.96
8.2.160.0140.00022.10
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00926.16
8.2.120.0050.00319.95
8.2.110.0080.00322.23
8.2.100.0090.00317.88
8.2.90.0000.00819.34
8.2.80.0000.00817.97
8.2.70.0070.00417.50
8.2.60.0030.00718.04
8.2.50.0030.00718.07
8.2.40.0030.00618.16
8.2.30.0040.00418.07
8.2.20.0060.00317.77
8.2.10.0000.00918.11
8.2.00.0030.00617.83
8.1.280.0110.00725.92
8.1.270.0080.00020.82
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0060.00323.92
8.1.230.0060.00617.50
8.1.220.0000.01017.78
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0040.00417.36
8.1.180.0000.00818.10
8.1.170.0000.00818.50
8.1.160.0030.00621.91
8.1.150.0080.00018.92
8.1.140.0000.00819.15
8.1.130.0040.00417.90
8.1.120.0040.00417.51
8.1.110.0060.00317.54
8.1.100.0030.00617.48
8.1.90.0040.00417.50
8.1.80.0060.00317.45
8.1.70.0090.00017.41
8.1.60.0000.00917.61
8.1.50.0080.00017.55
8.1.40.0050.00517.53
8.1.30.0030.00617.68
8.1.20.0040.00417.74
8.1.10.0000.00817.58
8.1.00.0050.00517.51
8.0.300.0030.00518.77
8.0.290.0040.00416.63
8.0.280.0040.00418.41
8.0.270.0050.00217.30
8.0.260.0000.00717.29
8.0.250.0070.00017.03
8.0.240.0070.00316.89
8.0.230.0000.00816.91
8.0.220.0080.00016.91
8.0.210.0090.00016.90
8.0.200.0030.00516.96
8.0.190.0000.00817.02
8.0.180.0080.00016.95
8.0.170.0000.00916.92
8.0.160.0060.00316.99
8.0.150.0050.00316.92
8.0.140.0060.00316.92
8.0.130.0030.00313.39
8.0.120.0080.00016.83
8.0.110.0030.00616.86
8.0.100.0040.00416.90
8.0.90.0040.00416.76
8.0.80.0030.01316.83
8.0.70.0040.00416.75
8.0.60.0040.00416.81
8.0.50.0050.00516.72
8.0.30.0080.01617.18
8.0.20.0100.01217.42
8.0.10.0000.00816.93
8.0.00.0150.00716.82
7.4.330.0070.00015.09
7.4.320.0000.00716.50
7.4.300.0030.00316.53
7.4.290.0000.00816.61
7.4.280.0000.00816.62
7.4.270.0000.00816.56
7.4.260.0030.00516.41
7.4.250.0050.00516.54
7.4.240.0020.00716.52
7.4.230.0000.00816.65
7.4.220.0090.01016.49
7.4.210.0060.01316.61
7.4.200.0060.00316.42
7.4.160.0130.00316.43
7.4.150.0070.01317.40
7.4.140.0130.00617.86
7.4.130.0080.01016.61
7.4.120.0110.00816.50
7.4.110.0190.00016.34
7.4.100.0090.00916.57
7.4.90.0040.01516.48
7.4.80.0150.00916.80
7.4.70.0060.01116.36
7.4.60.0210.00016.40
7.4.50.0030.00716.46
7.4.40.0060.01616.39
7.4.30.0170.00716.57
7.4.00.0050.01315.01
7.3.330.0040.00413.32
7.3.320.0040.00813.25
7.3.310.0040.00416.39
7.3.300.0070.00016.27
7.3.290.0000.00816.36
7.3.280.0090.00716.38
7.3.270.0180.00017.40
7.3.260.0040.01516.36
7.3.250.0120.00616.50
7.3.240.0120.00816.33
7.3.230.0070.01716.39
7.3.210.0070.01016.60
7.3.200.0060.01619.39
7.3.190.0040.01416.41
7.3.180.0090.00916.38
7.3.170.0150.00516.39
7.3.160.0190.00316.61
7.3.120.0030.01715.13
7.3.110.0060.01314.87
7.3.100.0040.00814.46
7.3.90.0120.00314.68
7.3.80.0000.01514.77
7.3.70.0080.01214.95
7.3.60.0060.00914.83
7.3.50.0030.00714.98
7.3.40.0110.00714.90
7.3.30.0090.00914.89
7.3.20.0030.01716.91
7.3.10.0040.01216.52
7.3.00.0070.00716.71
7.2.330.0070.01316.83
7.2.320.0030.01416.84
7.2.310.0060.01216.70
7.2.300.0060.01216.50
7.2.290.0000.02016.64
7.2.250.0120.00615.01
7.2.240.0070.01315.41
7.2.230.0120.00615.38
7.2.220.0060.00815.29
7.2.210.0060.01015.11
7.2.200.0070.00715.28
7.2.190.0100.00614.80
7.2.180.0100.00715.35
7.2.170.0090.00315.25
7.2.130.0030.01217.04
7.2.120.0130.00716.80
7.2.110.0040.00717.05
7.2.100.0050.00516.93
7.2.90.0030.01316.98
7.2.80.0030.01416.74
7.2.70.0180.00416.54
7.2.60.0110.00516.74
7.2.50.0070.01016.85
7.2.40.0080.00416.76
7.2.30.0070.01017.19
7.2.20.0080.00816.75
7.2.10.0030.01416.80
7.2.00.0040.01218.00
7.1.330.0100.00715.94
7.1.320.0030.01015.98
7.1.310.0040.01515.88
7.1.300.0070.00415.75
7.1.290.0070.01015.89
7.1.280.0060.01215.55
7.1.270.0090.01215.90
7.1.260.0030.01515.78
7.1.250.0030.01315.70
7.1.240.0000.01515.43
7.1.230.0110.00415.84
7.1.220.0040.01215.77
7.1.210.0090.00615.88
7.1.200.0030.00915.88
7.1.190.0040.01115.96
7.1.180.0060.00915.66
7.1.170.0090.00315.59
7.1.160.0070.01015.61
7.1.150.0040.00816.00
7.1.140.0070.01015.89
7.1.130.0000.01515.82
7.1.120.0070.01015.86
7.1.110.0000.01715.48
7.1.100.0050.01216.98
7.1.90.0000.01915.75
7.1.80.0030.01215.88
7.1.70.0030.00916.43
7.1.60.0060.01017.64
7.1.50.0030.01416.34
7.1.40.0060.00915.82
7.1.30.0090.00315.86
7.1.20.0090.00615.87
7.1.10.0070.01015.97
7.1.00.0070.04219.17
7.0.330.0040.00715.54
7.0.320.0080.00315.23
7.0.310.0090.00315.35
7.0.300.0080.00615.43
7.0.290.0030.01215.43
7.0.280.0030.01315.51
7.0.270.0030.00815.48
7.0.260.0000.01415.27
7.0.250.0070.01015.55
7.0.240.0060.00915.62
7.0.230.0000.01915.40
7.0.220.0130.00315.37
7.0.210.0120.00615.23
7.0.200.0050.00715.17
7.0.190.0030.00715.33
7.0.180.0100.00615.30
7.0.170.0040.01215.58
7.0.160.0060.00615.55
7.0.150.0080.00815.41
7.0.140.0100.02018.62
7.0.130.0060.00915.43
7.0.120.0070.00715.12
7.0.110.0060.01315.37
7.0.100.0000.02015.55
7.0.90.0040.01115.55
7.0.80.0000.01315.49
7.0.70.0060.01015.17
7.0.60.0130.04517.62
7.0.50.0030.03316.60
7.0.40.0120.03316.89
7.0.30.0180.02316.95
7.0.20.0280.04116.78
7.0.10.0020.03416.84
7.0.00.0090.03916.81
5.6.380.0030.01714.37
5.6.370.0030.01714.39
5.6.360.0090.01314.66
5.6.350.0060.01614.33
5.6.340.0030.01714.39
5.6.330.0080.02214.55
5.6.320.0070.01114.79
5.6.310.0100.01314.62
5.6.300.0110.01414.63
5.6.290.0060.02114.64
5.6.280.0050.04617.66
5.6.270.0030.02314.56
5.6.260.0100.01014.68
5.6.250.0030.02114.50
5.6.240.0070.01014.59
5.6.230.0060.01514.55
5.6.220.0090.00914.48
5.6.210.0040.04217.51
5.6.200.0020.05316.28
5.6.190.0060.04817.42
5.6.180.0180.04817.53
5.6.170.0100.03517.59
5.6.160.0110.02717.40
5.6.150.0030.03716.36
5.6.140.0030.05516.35
5.6.130.0080.03216.31
5.6.120.0130.04817.69
5.6.110.0050.03817.72
5.6.100.0120.04917.79
5.6.90.0070.05517.87
5.6.80.0130.04517.36
5.6.70.0100.01714.48
5.6.60.0120.01214.12
5.6.50.0200.01514.28
5.6.40.0070.01414.38
5.6.30.0060.02214.15
5.6.20.0130.00614.46
5.6.10.0090.01514.53
5.6.00.0070.03014.34
5.5.380.0000.01811.31
5.5.370.0060.01311.18
5.5.360.0000.01311.46
5.5.350.0160.02115.79
5.5.340.0020.03714.71
5.5.330.0030.03215.90
5.5.320.0030.03915.77
5.5.310.0170.04815.88
5.5.300.0060.03414.44
5.5.290.0080.04314.56
5.5.280.0100.03916.16
5.5.270.0080.03116.16
5.5.260.0100.04916.04
5.5.250.0120.04315.99
5.5.240.0180.04515.80
5.5.230.0040.02111.05
5.5.220.0090.00911.08
5.5.210.0130.01011.07
5.5.200.0060.01211.29
5.5.190.0040.01811.25
5.5.180.0040.01510.83
5.5.170.0040.00911.38
5.5.160.0100.00711.39
5.5.150.0000.01711.46
5.5.140.0040.01511.20
5.5.130.0030.01311.43
5.5.120.0040.01511.35
5.5.110.0040.01511.27
5.5.100.0090.00611.24
5.5.90.0090.00911.08
5.5.80.0060.00911.41
5.5.70.0060.01211.25
5.5.60.0100.01410.73
5.5.50.0000.01910.85
5.5.40.0090.01611.06
5.5.30.0090.01311.39
5.5.20.0100.00711.21
5.5.10.0000.01711.29
5.5.00.0070.01011.06
5.4.450.0130.02815.39
5.4.440.0130.03915.30
5.4.430.0130.02715.40
5.4.420.0140.04615.07
5.4.410.0140.04915.26
5.4.400.0160.03115.04
5.4.390.0110.03715.04
5.4.380.0100.03515.33
5.4.370.0130.03415.12
5.4.360.0180.04615.22
5.4.350.0120.04715.06
5.4.340.0160.03615.21
5.4.330.0150.00811.23
5.4.320.0140.04715.14
5.4.310.0120.04815.06
5.4.300.0170.03714.96
5.4.290.0170.02815.02
5.4.280.0180.04315.15
5.4.270.0100.04015.12
5.4.260.0150.03215.25
5.4.250.0180.04215.04
5.4.240.0170.04015.08
5.4.230.0200.03815.00
5.4.220.0200.04215.06
5.4.210.0120.03115.11
5.4.200.0190.04215.12
5.4.190.0170.02615.05
5.4.180.0150.04515.17
5.4.170.0100.03115.12
5.4.160.0210.04315.20
5.4.150.0170.03614.84
5.4.140.0100.03313.88
5.4.130.0170.02813.88
5.4.120.0180.04213.73
5.4.110.0110.03313.99
5.4.100.0240.04313.59
5.4.90.0170.03513.75
5.4.80.0170.04113.89
5.4.70.0120.04213.70
5.4.60.0100.04913.78
5.4.50.0130.03313.88
5.4.40.0120.04413.61
5.4.30.0080.03713.75
5.4.20.0110.04813.83
5.4.10.0100.04913.66
5.4.00.0130.02813.49
5.3.290.0110.04212.51
5.3.280.0100.03512.37
5.3.270.0100.02412.43
5.3.260.0190.04012.42
5.3.250.0140.03012.44
5.3.240.0120.01812.45
5.3.230.0150.02012.42
5.3.220.0190.02912.38
5.3.210.0150.02812.41
5.3.200.0170.03312.43
5.3.190.0150.03412.46
5.3.180.0170.02712.47
5.3.170.0170.03212.53
5.3.160.0150.02512.44
5.3.150.0120.03212.45
5.3.140.0120.02712.49
5.3.130.0150.03512.51
5.3.120.0130.02112.42
5.3.110.0120.02712.47
5.3.100.0090.04412.19
5.3.90.0220.04312.33
5.3.80.0160.03312.19
5.3.70.0290.02212.22
5.3.60.0080.03012.12
5.3.50.0170.02012.20
5.3.40.0080.03312.22
5.3.30.0180.03312.07
5.3.20.0130.03312.00
5.3.10.0180.03211.99
5.3.00.0150.03711.89
5.2.170.0140.01811.17
5.2.160.0100.02611.17
5.2.150.0130.03211.17
5.2.140.0080.02811.17
5.2.130.0150.02511.17
5.2.120.0130.02811.17
5.2.110.0140.02011.17
5.2.100.0130.02011.17
5.2.90.0110.02011.17
5.2.80.0150.03011.17
5.2.70.0050.03211.17
5.2.60.0120.03111.17
5.2.50.0120.02711.17
5.2.40.0150.02811.17
5.2.30.0090.03011.17
5.2.20.0080.02211.17
5.2.10.0090.02911.17
5.2.00.0180.01511.17
5.1.60.0080.02511.17
5.1.50.0160.02011.17
5.1.40.0170.01011.17
5.1.30.0130.02711.17
5.1.20.0160.02211.17
5.1.10.0100.02711.17
5.1.00.0030.02911.17
5.0.50.0060.02511.17
5.0.40.0040.02711.17
5.0.30.0040.02011.17
5.0.20.0080.01711.17
5.0.10.0070.01611.17
5.0.00.0080.03511.17
4.4.90.0080.01211.17
4.4.80.0030.02211.17
4.4.70.0020.01811.17
4.4.60.0070.01511.17
4.4.50.0080.01611.17
4.4.40.0050.02911.17
4.4.30.0080.01511.17
4.4.20.0100.01711.17
4.4.10.0050.02011.17
4.4.00.0030.02611.17
4.3.110.0050.01311.17
4.3.100.0050.01611.17
4.3.90.0070.01411.17
4.3.80.0100.01311.17
4.3.70.0050.01811.17
4.3.60.0070.01511.17
4.3.50.0050.01311.17
4.3.40.0050.02011.17
4.3.30.0000.01511.17
4.3.20.0060.01011.17
4.3.10.0020.02011.17
4.3.00.0030.01811.17

preferences:
57.62 ms | 401 KiB | 5 Q