3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait TimeRestriction{ public function excludeTimes($times, $restrictions) { $timeList = $this->mergeTimes($times, $restrictions); var_dump($timeList); $validTimes = []; $result = []; foreach ($timeList as $key => $time) { $restrictionInclusive = false; if ($key == count($timeList) - 1) { $restrictionInclusive = true; } if ($this->isTimeWithinRanges($time, $times) && !$this->isTimeWithinRanges($time, $restrictions, $restrictionInclusive)) { $validTimes[] = $time; } } $validItemsCount = count($validTimes); for ($i = 0; $i < $validItemsCount; $i += 2) { $result[] = [ 'start_time' => $validTimes[$i], 'end_time' => $validTimes[$i + 1] ]; } return $result; } public function isTimeWithinRanges($time, $ranges, $inclusive = true) { foreach ($ranges as $range) { if ($this->isTimeWithinRange($time, $range, $inclusive)) { return true; } } return false; } public function isTimeWithinRange($time, $range, $inclusive = true) { if ($inclusive) { return $time->gte($range['start_time']) && $time->lte($range['end_time']); } else { return $time->gt($range['start_time']) && $time->lt($range['end_time']); } } public function mergeTimes() { $allTimes = collect([]); $params = func_get_args(); foreach ($params as $param) { foreach ($param as $timeRange) { $allTimes->push($timeRange['start_time']); $allTimes->push($timeRange['end_time']); } } var_dump($allTimes->toArray()); return $allTimes->sortBy(function (Carbon $value, $key) { return $value->getTimestamp(); })->values()->unique(function (Carbon $value) { return $value->getTimestamp(); })->all(); } }

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.5.10.0120.00718.25
8.5.00.0130.00819.93
8.4.150.0020.00014.05
8.4.140.0130.00817.33
8.4.130.0130.00618.79
8.4.120.0110.00820.59
8.4.110.0120.00820.56
8.4.100.0120.00917.76
8.4.90.0110.00818.41
8.4.80.0130.00817.64
8.4.70.0010.00717.68
8.4.60.0070.00120.39
8.4.50.0110.01017.46
8.4.40.0050.00319.03
8.4.30.0000.02017.73
8.4.20.0130.00317.43
8.4.10.0070.00317.63
8.3.280.0110.01018.57
8.3.270.0100.01016.31
8.3.260.0100.00916.47
8.3.250.0110.00817.08
8.3.240.0100.00516.63
8.3.230.0140.00516.41
8.3.220.0120.00717.29
8.3.210.0060.00216.49
8.3.200.0040.00516.66
8.3.190.0130.00716.69
8.3.180.0130.00818.17
8.3.170.0120.00916.39
8.3.160.0080.01117.93
8.3.150.0150.00417.00
8.3.140.0060.01217.11
8.3.130.0120.00918.55
8.3.120.0080.01118.69
8.3.110.0040.00720.94
8.3.100.0090.00616.66
8.3.90.0040.00416.64
8.3.80.0030.00618.18
8.3.70.0060.00916.63
8.3.60.0070.01418.18
8.3.50.0160.00516.43
8.3.40.0110.00718.46
8.3.30.0140.00018.54
8.3.20.0000.00720.15
8.3.10.0080.00021.84
8.3.00.0050.00320.89
8.2.290.0080.01020.33
8.2.280.0030.00520.00
8.2.270.0140.00416.35
8.2.260.0000.00716.36
8.2.250.0060.01216.44
8.2.240.0030.01218.91
8.2.230.0080.00022.58
8.2.220.0030.00537.54
8.2.210.0110.00726.77
8.2.200.0030.00616.38
8.2.190.0090.00916.58
8.2.180.0060.01216.63
8.2.170.0090.00922.96
8.2.160.0120.00419.25
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0050.00219.70
8.2.120.0090.00026.35
8.2.110.0060.00320.99
8.2.100.0070.00717.59
8.2.90.0000.00817.63
8.2.80.0040.00418.52
8.2.70.0040.00417.63
8.2.60.0090.00017.68
8.2.50.0040.00418.07
8.2.40.0080.00019.62
8.2.30.0040.00418.04
8.2.20.0000.00817.89
8.2.10.0050.00318.02
8.2.00.0070.00017.88
8.1.330.0090.01021.83
8.1.320.0100.00915.92
8.1.310.0060.00316.22
8.1.300.0040.00418.28
8.1.290.0040.00418.88
8.1.280.0040.01125.92
8.1.270.0030.00723.86
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0070.00319.42
8.1.230.0040.00817.70
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0030.00617.22
8.1.190.0040.00417.10
8.1.180.0000.00818.10
8.1.170.0000.00818.59
8.1.160.0040.00418.70
8.1.150.0000.00720.34
8.1.140.0040.00419.51
8.1.130.0030.00618.75
8.1.120.0000.00717.34
8.1.110.0000.00817.29
8.1.100.0040.00417.29
8.1.90.0050.00217.42
8.1.80.0050.00317.28
8.1.70.0070.00017.39
8.1.60.0030.00617.41
8.1.50.0090.00017.36
8.1.40.0030.00517.36
8.1.30.0000.00917.39
8.1.20.0040.00417.60
8.1.10.0040.00417.38
8.1.00.0090.00017.31
8.0.300.0050.00318.77
8.0.290.0000.00816.63
8.0.280.0050.00218.43
8.0.270.0030.00317.21
8.0.260.0030.00318.78
8.0.250.0070.00016.90
8.0.240.0050.00316.77
8.0.230.0040.00416.79
8.0.220.0030.00316.77
8.0.210.0040.00416.70
8.0.200.0040.00416.77
8.0.190.0000.00816.82
8.0.180.0030.00616.75
8.0.170.0050.00216.83
8.0.160.0030.00416.77
8.0.150.0040.00416.80
8.0.140.0040.00416.77
8.0.130.0040.00413.22
8.0.120.0070.00016.77
8.0.110.0000.00816.59
8.0.100.0000.00716.64
8.0.90.0030.00316.84
8.0.80.0140.01016.69
8.0.70.0000.00716.82
8.0.60.0030.00516.75
8.0.50.0000.00716.77
8.0.30.0110.00917.09
8.0.20.0060.01217.40
8.0.10.0000.00716.89
8.0.00.0070.01016.57
7.4.330.0000.00515.55
7.4.320.0060.00016.53
7.4.300.0030.00316.42
7.4.290.0030.00316.31
7.4.280.0050.00316.40
7.4.270.0030.00316.43
7.4.260.0000.00916.41
7.4.250.0040.00416.39
7.4.240.0080.00016.53
7.4.230.0030.00316.59
7.4.220.0060.01216.40
7.4.210.0080.01016.51
7.4.200.0030.00316.32
7.4.160.0090.00816.51
7.4.150.0150.00317.40
7.4.140.0090.01017.86
7.4.130.0090.01016.42
7.4.120.0110.00716.42
7.4.110.0030.01416.33
7.4.100.0120.00616.30
7.4.90.0110.00716.61
7.4.80.0090.00919.39
7.4.70.0130.00316.39
7.4.60.0130.00316.36
7.4.50.0120.00316.36
7.4.40.0070.01016.52
7.4.30.0150.00916.48
7.4.00.0090.00614.60
7.3.330.0060.00013.07
7.3.320.0050.00013.07
7.3.310.0040.00416.10
7.3.300.0000.00716.25
7.3.290.0030.00316.07
7.3.280.0100.00716.19
7.3.270.0090.01217.40
7.3.260.0100.01016.36
7.3.250.0110.01016.29
7.3.240.0070.01016.26
7.3.230.0060.01616.36
7.3.210.0140.00716.23
7.3.200.0040.01216.33
7.3.190.0040.01116.48
7.3.180.0070.01016.09
7.3.170.0040.01216.27
7.3.160.0100.01416.38
7.2.330.0090.01516.32
7.2.320.0030.01316.32
7.2.310.0120.00616.48
7.2.300.0090.00916.50
7.2.290.0080.00816.48
7.2.60.0120.00316.69
7.1.200.0080.00815.51
7.1.80.0070.01017.73
7.1.70.0000.01717.13
7.1.60.0220.01434.96
7.1.50.0200.01734.56
7.1.40.0230.01234.26
7.1.30.0210.01434.22
7.1.20.0230.01734.23
7.1.10.0060.01416.30
7.1.00.0090.01116.61
7.0.200.0000.01616.69
7.0.190.0090.00916.34
7.0.180.0090.01116.25
7.0.170.0070.01015.97
7.0.160.0060.01216.25
7.0.150.0130.00416.01
7.0.140.0070.01016.20
7.0.130.0110.00716.36
7.0.120.0080.00916.06
7.0.110.0090.00616.03
7.0.100.0020.01616.25
7.0.90.0060.01416.04
7.0.80.0060.01016.11
7.0.70.0080.01215.87
7.0.60.0060.01315.99
7.0.50.0100.00916.27
7.0.40.0030.01316.40
7.0.30.0030.01216.44
7.0.20.0090.00616.33
7.0.10.0040.01016.46
7.0.00.0090.00916.33

preferences:
170.85 ms | 403 KiB | 5 Q