3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class RangesUtil { final private function __construct() {} /** * @param array $element * * @return int[] * Format: $[$value] = $count */ static function elementExtractUnsortedStats(array $element) { $rawStats = array(); foreach ($element as $value => $item) { if (isset($item['#count']) && is_int($item['#count'])) { $rawStats[$value] = $item['#count']; } } return $rawStats; } /** * @param float[]|int[] $steps * Format: $[] = $stepValue * @param int[] $ustats * (unsorted) stats. * Format: $[$value] = $count * @param bool $below * TRUE to accumulate below, FALSE to accumulate above. * @param bool $dedupe * * @return int[] * Format: $[$value] = $countAccum */ static function stepsUstatsAccumulate(array $steps, array $ustats, $below, $dedupe = FALSE) { $statsCombined = $ustats + array_fill_keys($steps, 0); ksort($statsCombined, SORT_NUMERIC); $statsCombinedAccum = self::statsAccumulate($statsCombined, $below); $stepsAccum = array(); foreach ($steps as $step) { $stepsAccum[$step] = $statsCombinedAccum[$step]; } if ($dedupe) { $stepsAccum = self::statsAccumDedupe($stepsAccum, $below); } return $stepsAccum; } /** * @param int[] $statsAccum * Format: $[$value] = $countAccum * @param bool $below * * @return int[] * Format: $[$value] = $countAccum */ static function statsAccumDedupe(array $statsAccum, $below) { $countPrev = NULL; foreach ($below ? $statsAccum : array_reverse($statsAccum, TRUE) as $value => $countAccum) { if ($countPrev === $countAccum) { unset($statsAccum[$value]); } } return $statsAccum; } /** * @param array $rawStats * * @return int[] * Format: $[$value] = $count */ static function unsortedStatsGetStats(array $rawStats) { ksort($rawStats, SORT_NUMERIC); return $rawStats; } /** * @param int[] $stats * (sorted) stats. * Format: $[$value] = $count * @param bool $below * TRUE to accumulate below, FALSE to accumulate above. * * @return int[] * Format: $[$value] = $countAccum */ static function statsAccumulate(array $stats, $below) { $total = 0; foreach ($below ? $stats : array_reverse($stats, TRUE) as $value => $count) { $total += $count; $stats[$value] = $total; } return $stats; } } $ustats = array( 0 => 2, 3 => 10, 7 => 100, 8 => 1000, 19 => 10000, ); $steps = array(0, 2, 5, 10, 20); var_export(RangesUtil::stepsUstatsAccumulate($steps, $ustats));

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.0180.00018.55
8.3.50.0140.00721.02
8.3.40.0110.00418.86
8.3.30.0120.00318.85
8.3.20.0000.00720.21
8.3.10.0040.00423.51
8.3.00.0070.00021.85
8.2.180.0000.01816.88
8.2.170.0090.00622.96
8.2.160.0120.00320.47
8.2.150.0040.01124.18
8.2.140.0080.00024.66
8.2.130.0040.00420.79
8.2.120.0040.00426.35
8.2.110.0000.00920.53
8.2.100.0040.00817.84
8.2.90.0080.00019.08
8.2.80.0040.00417.97
8.2.70.0030.00617.50
8.2.60.0000.00918.04
8.2.50.0060.00318.09
8.2.40.0030.00522.21
8.2.30.0040.00419.34
8.2.20.0050.00317.67
8.2.10.0000.00818.02
8.2.00.0080.00017.98
8.1.280.0070.00725.92
8.1.270.0080.00022.27
8.1.260.0040.00428.09
8.1.250.0000.00828.09
8.1.240.0040.01223.90
8.1.230.0080.00421.04
8.1.220.0000.00817.79
8.1.210.0060.00318.77
8.1.200.0090.00017.34
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0040.00418.47
8.1.160.0070.00020.75
8.1.150.0030.00518.96
8.1.140.0040.00417.43
8.1.130.0060.00317.61
8.1.120.0040.00417.41
8.1.110.0040.00417.43
8.1.100.0040.00417.37
8.1.90.0000.00717.37
8.1.80.0050.00317.31
8.1.70.0030.00317.34
8.1.60.0030.00517.57
8.1.50.0000.00817.57
8.1.40.0000.00817.57
8.1.30.0060.00317.72
8.1.20.0050.00317.64
8.1.10.0000.00817.70
8.1.00.0040.00417.60
8.0.300.0000.00818.77
8.0.290.0050.00316.88
8.0.280.0050.00218.46
8.0.270.0070.00016.81
8.0.260.0000.00617.12
8.0.250.0030.00316.93
8.0.240.0050.00216.88
8.0.230.0000.00717.02
8.0.220.0060.00316.95
8.0.210.0070.00016.93
8.0.200.0060.00316.87
8.0.190.0030.01017.01
8.0.180.0000.00816.97
8.0.170.0040.00417.01
8.0.160.0000.00716.91
8.0.150.0040.00416.90
8.0.140.0000.00716.80
8.0.130.0030.00313.37
8.0.120.0040.00416.96
8.0.110.0040.00416.78
8.0.100.0050.00216.97
8.0.90.0030.00716.72
8.0.80.0120.00916.88
8.0.70.0040.00416.97
8.0.60.0000.00816.99
8.0.50.0030.00516.88
8.0.30.0090.01017.07
8.0.20.0080.01217.40
8.0.10.0070.00017.13
8.0.00.0090.00816.59
7.4.330.0020.00216.76
7.4.320.0030.00316.62
7.4.300.0040.00416.70
7.4.290.0000.00716.49
7.4.280.0040.00416.55
7.4.270.0030.00316.67
7.4.260.0000.01016.60
7.4.250.0040.00416.62
7.4.240.0000.00816.66
7.4.230.0070.00016.42
7.4.220.0110.00716.50
7.4.210.0070.01016.58
7.4.200.0000.00716.40
7.4.160.0060.01016.48
7.4.150.0040.01517.40
7.4.140.0130.00817.86
7.4.130.0100.00716.57
7.4.120.0090.00916.63
7.4.110.0100.00716.62
7.4.100.0090.00916.56
7.4.90.0150.00416.58
7.4.80.0160.00319.39
7.4.70.0080.00916.66
7.4.60.0090.01216.52
7.4.50.0000.01116.48
7.4.40.0070.01116.51
7.4.30.0140.00416.44
7.4.00.0000.01415.08
7.3.330.0000.00813.41
7.3.320.0070.00013.22
7.3.310.0000.00816.43
7.3.300.0030.00316.45
7.3.290.0050.00216.47
7.3.280.0120.00616.39
7.3.270.0040.01417.40
7.3.260.0130.00716.36
7.3.250.0100.00716.58
7.3.240.0060.01116.47
7.3.230.0130.00516.47
7.3.210.0060.01016.52
7.3.200.0060.01519.39
7.3.190.0120.00616.59
7.3.180.0100.00716.44
7.3.170.0150.00316.54
7.3.160.0150.00816.39
7.2.330.0150.00416.50
7.2.320.0030.01416.56
7.2.310.0090.00916.49
7.2.300.0090.00916.59
7.2.290.0130.00316.67
7.2.60.0070.00716.63
7.2.00.0080.00819.36
7.1.200.0030.00915.44
7.1.100.0060.00618.11
7.1.70.0040.00417.25
7.1.60.0060.01919.40
7.1.50.0040.01816.88
7.1.00.0030.07722.36
7.0.200.0180.00714.82
7.0.60.0330.05719.86
7.0.50.0000.04717.75
7.0.40.0070.04720.09
7.0.30.0200.04020.26
7.0.20.0300.04020.28
7.0.10.0000.05020.22
7.0.00.0030.04320.07
5.6.280.0030.06321.13
5.6.210.0100.08320.46
5.6.200.0070.03718.22
5.6.190.0100.08720.63
5.6.180.0230.03720.42
5.6.170.0200.04020.71
5.6.160.0070.08720.61
5.6.150.0130.07318.18
5.6.140.0030.07718.15
5.6.130.0070.05318.18
5.6.120.0030.06721.03
5.6.110.0030.07321.10
5.6.100.0070.08721.05
5.6.90.0030.07720.98
5.6.80.0130.07320.54
5.5.350.0200.08720.38
5.5.340.0100.07718.00
5.5.330.0100.08020.56
5.5.320.0100.04720.41
5.5.310.0400.05320.35
5.5.300.0070.06718.04
5.5.290.0070.05317.99
5.5.280.0070.05020.67
5.5.270.0030.04020.88
5.5.260.0000.05020.98
5.5.250.0070.05320.63
5.5.240.0230.09020.38

preferences:
52.84 ms | 401 KiB | 5 Q