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($a['drupalSettings']) && !empty($b['drupalSettings'])) { $drupalSettings = mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE); // No need for re-merging them. unset($a['drupalSettings']); unset($b['drupalSettings']); } // Apply the normal merge. $a = mergeDeepArray(array($a, $b)); if (isset($drupalSettings)) { // Save the custom merge for the drupalSettings. $a['drupalSettings'] = $drupalSettings; } return $a; } 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 <= 100000; $i++) { $a['#attached'] = array( 'library' => array( 'core/drupal', 'core/drupalSettings', ), 'drupalSettings' => [ 'bar' => ['a', 'b', 'c'], ], 'js' => array( 'baz.js' => array(), ), ); $b['#attached'] = array( 'library' => array( 'core/jquery', ), 'js' => array( 'foo.js' => array(), 'bar.js' => array(), ), 'drupalSettings' => [ 'foo' => ['d'], ], ); 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.0100.19116.50
8.3.50.0120.19322.11
8.3.40.0130.17718.67
8.3.30.0160.16119.17
8.3.20.0030.09120.34
8.3.10.0030.09321.81
8.3.00.0030.09120.84
8.2.180.0100.18416.75
8.2.170.0100.17722.96
8.2.160.0100.16422.13
8.2.150.0100.09424.18
8.2.140.0100.10924.66
8.2.130.0000.09426.16
8.2.120.0000.10119.83
8.2.110.0070.19222.16
8.2.100.0100.18017.91
8.2.90.0030.16219.37
8.2.80.0070.15417.97
8.2.70.0070.15817.63
8.2.60.0000.16318.16
8.2.50.0100.15418.07
8.2.40.0030.15718.21
8.2.30.0000.18218.02
8.2.20.0070.15617.75
8.2.10.0100.15318.20
8.2.00.0100.15617.69
8.1.280.0100.19325.92
8.1.270.0130.09520.60
8.1.260.0100.08426.35
8.1.250.0100.11728.09
8.1.240.0070.19123.97
8.1.230.0030.15717.95
8.1.220.0030.15817.74
8.1.210.0030.16518.77
8.1.200.0070.15917.35
8.1.190.0000.16617.35
8.1.180.0000.16218.10
8.1.170.0030.14918.65
8.1.160.0000.15022.08
8.1.150.0070.15218.82
8.1.140.0030.16019.11
8.1.130.0030.15417.83
8.1.120.0030.16617.41
8.1.110.0070.15717.46
8.1.100.0000.16417.45
8.1.90.0030.16017.38
8.1.80.0000.16317.46
8.1.70.0030.16317.49
8.1.60.0030.18417.64
8.1.50.0000.18717.54
8.1.40.0000.18817.55
8.1.30.0030.18417.66
8.1.20.0000.18717.62
8.1.10.0070.18017.58
8.1.00.0100.23017.59
8.0.300.0030.15518.77
8.0.290.0030.17016.63
8.0.280.0030.16818.52
8.0.270.0000.17317.34
8.0.260.0070.19117.27
8.0.250.0030.16916.91
8.0.240.0070.17216.97
8.0.230.0000.17316.93
8.0.220.0030.17216.90
8.0.210.0030.16916.93
8.0.200.0030.19316.98
8.0.190.0070.18316.89
8.0.180.0070.18916.91
8.0.170.0030.19216.98
8.0.160.0000.19016.94
8.0.150.0030.18716.74
8.0.140.0030.18716.88
8.0.130.0000.18813.34
8.0.120.0030.18616.77
8.0.110.0030.18616.94
8.0.100.0070.18416.91
8.0.90.0000.19216.91
8.0.80.0030.25716.96
8.0.70.0030.18816.89
8.0.60.0030.18816.95
8.0.50.0030.18916.79
8.0.30.0150.33217.12
8.0.20.0130.25417.40
8.0.10.0030.19017.02
8.0.00.0080.28716.66
7.4.330.0030.16715.07
7.4.320.0070.17016.50
7.4.300.0000.18216.46
7.4.290.0000.19216.66
7.4.280.0030.19616.57
7.4.270.0030.18816.50
7.4.260.0030.22516.49
7.4.250.0130.20916.39
7.4.240.0030.19316.61
7.4.230.0030.18916.50
7.4.220.0100.29116.71
7.4.210.0100.34616.52
7.4.200.0030.18916.62
7.4.160.0200.24416.75
7.4.150.0100.28617.40
7.4.140.0080.30517.86
7.4.130.0060.29716.46
7.4.120.0120.27416.56
7.4.110.0160.43116.43
7.4.100.0100.44816.64
7.4.90.0130.28916.36
7.4.80.0060.30816.43
7.4.70.0100.27816.52
7.4.60.0100.24616.49
7.4.50.0030.13716.30
7.4.40.0100.26216.61
7.4.30.0030.29416.50
7.4.00.0070.32415.01
7.3.330.0070.19413.38
7.3.320.0030.20413.46
7.3.310.0070.19216.45
7.3.300.0030.19316.31
7.3.290.0030.22216.26
7.3.280.0030.33916.35
7.3.270.0090.31517.40
7.3.260.0130.26816.63
7.3.250.0150.29616.54
7.3.240.0280.35116.43
7.3.230.0060.26816.46
7.3.210.0260.32916.59
7.3.200.0060.37419.39
7.3.190.0060.25816.44
7.3.180.0060.26316.64
7.3.170.0100.28316.64
7.3.160.0160.29416.41
7.2.330.0160.29016.41
7.2.320.0170.29516.50
7.2.310.0220.38316.77
7.2.300.0060.30416.53
7.2.290.0100.31716.48
7.2.60.0100.16316.67
7.1.200.0000.18615.87
7.1.70.0000.17617.21
7.1.60.0130.22319.46
7.1.50.0260.16816.52
7.1.00.0030.33022.45
7.0.200.0070.19414.88
7.0.140.0030.29722.01
7.0.60.0030.28019.80
7.0.50.0070.25317.82
7.0.40.0070.25019.98
7.0.30.0070.23320.16
7.0.20.0300.31320.09
7.0.10.0000.23720.22
7.0.00.0030.22020.27
5.6.280.0070.88021.05
5.6.210.0030.83720.65
5.6.200.0070.83318.16
5.6.190.0000.82020.33
5.6.180.0430.78720.33
5.6.170.0300.82020.44
5.6.160.0100.84020.47
5.6.150.0000.76318.19
5.6.140.0000.77318.29
5.6.130.0030.85718.21
5.6.120.0200.84020.99
5.6.110.0130.79320.97
5.6.100.1170.81321.03
5.6.90.0030.76021.01
5.6.80.0100.84020.39
5.5.350.0330.94320.32
5.5.340.0030.83317.94
5.5.330.0100.91720.27
5.5.320.0070.91320.20
5.5.310.0070.85720.28
5.5.300.0070.93017.98
5.5.290.0000.90017.93
5.5.280.0130.92020.66
5.5.270.0130.88720.86
5.5.260.0130.91320.98
5.5.250.0070.90320.80
5.5.240.0070.93020.25
5.4.450.0531.41319.63
5.4.440.0931.55719.17
5.4.430.0031.45719.61
5.4.420.0901.62319.62
5.4.410.0901.48719.45
5.4.400.1231.44318.86
5.4.390.0231.73318.45
5.4.380.0171.71318.78
5.4.370.0171.43018.46
5.4.360.0201.51018.49
5.4.350.0271.76718.47
5.4.340.0331.49318.61
5.4.320.0371.62318.57
5.4.310.0371.69018.50
5.4.300.0171.58018.83
5.4.290.0531.63718.84
5.4.280.0201.59018.78
5.4.270.0171.66318.80
5.4.260.0201.60318.70
5.4.250.0201.56318.79
5.4.240.0171.61318.57
5.4.230.0201.44018.70
5.4.220.0201.49318.60
5.4.210.0231.48018.72
5.4.200.0371.79316.82
5.4.190.0101.52718.76
5.4.180.0231.52018.45
5.4.170.0371.52718.82
5.4.160.0231.54318.47
5.4.150.0231.52718.55
5.4.140.0331.80016.47
5.4.130.0371.74016.28
5.4.120.0301.52716.26
5.4.110.0271.58716.28
5.4.100.0201.52016.28
5.4.90.0131.42016.45
5.4.80.0232.22716.18
5.4.70.0201.63316.25
5.4.60.0271.90016.30
5.4.50.0171.61716.40
5.4.40.0031.60016.43
5.4.30.0171.61716.39
5.4.20.0201.65316.28
5.4.10.0071.50316.29
5.4.00.0171.66015.73
5.3.290.0170.05714.71
5.3.280.0130.06014.61
5.3.270.0100.06314.65
5.3.260.0170.06314.81
5.3.250.0170.05314.64
5.3.240.0200.04714.74
5.3.230.0170.05314.63
5.3.220.0170.05314.57
5.3.210.0230.05014.63
5.3.200.0270.04314.79
5.3.190.0270.04714.56
5.3.180.0130.05314.68
5.3.170.0200.05014.76
5.3.160.0230.05014.61
5.3.150.0200.06014.61
5.3.140.0300.04314.69
5.3.130.0300.05314.58
5.3.120.0170.06014.61
5.3.110.0200.05714.72
5.3.100.0100.06014.08
5.3.90.0130.05714.09
5.3.80.0230.04714.09
5.3.70.0170.05314.07
5.3.60.0230.04714.14
5.3.50.0200.05013.99
5.3.40.0230.04714.17
5.3.30.0170.05714.08
5.3.20.0300.03713.85
5.3.10.0100.05713.89
5.3.00.0130.05313.87
5.2.170.0170.04011.36
5.2.160.0200.03711.24
5.2.150.0130.05311.27
5.2.140.0070.05011.26
5.2.130.0130.06011.12
5.2.120.0200.03711.14
5.2.110.0100.04311.10
5.2.100.0130.05311.23
5.2.90.0200.03711.13
5.2.80.0130.04311.12
5.2.70.0170.05311.11
5.2.60.0130.04311.20
5.2.50.0170.05011.16
5.2.40.0070.05011.14
5.2.30.0170.05311.01
5.2.20.0170.04711.00
5.2.10.0130.05310.98
5.2.00.0200.05310.95
5.1.60.0100.03710.13
5.1.50.0230.03310.14
5.1.40.0200.04010.02
5.1.30.0130.05010.53
5.1.20.0130.03710.57
5.1.10.0100.05010.13
5.1.00.0100.03710.16
5.0.50.0030.0378.58
5.0.40.0030.0308.55
5.0.30.0000.0508.31
5.0.20.0070.0308.31
5.0.10.0130.0238.26
5.0.00.0170.0478.32
4.4.90.0070.0236.05
4.4.80.0100.0206.01
4.4.70.0100.0206.03
4.4.60.0070.0205.91
4.4.50.0100.0205.94
4.4.40.0100.0335.90
4.4.30.0030.0235.93
4.4.20.0100.0275.97
4.4.10.0100.0306.02
4.4.00.0070.0435.95
4.3.110.0130.0135.90
4.3.100.0000.0275.93
4.3.90.0100.0175.90
4.3.80.0100.0335.90
4.3.70.0100.0175.90
4.3.60.0000.0275.90
4.3.50.0030.0305.90
4.3.40.0030.0375.90
4.3.30.0070.0305.90
4.3.20.0000.0275.90
4.3.10.0070.0205.90
4.3.00.0100.01314.42

preferences:
43.39 ms | 401 KiB | 5 Q