3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Settings $workStartHour = 9; $workStartMin = 0; $workEndHour = 17; $workEndMin = 30; $workdayHours = 8.5; $weekends = ['Saturday', 'Sunday']; $hours = 0; // Original start and end times, and their clones that we'll modify. $originalStart = new DateTime('2014-06-25 11:30'); $start = clone $originalStart; // Starting on a weekend? Skip to a weekday. while (in_array($start->format('l'), $weekends)) { $start->modify('midnight tomorrow'); } $originalEnd = new DateTime('2014-07-22 12:30'); $end = clone $originalEnd; // Ending on a weekend? Go back to a weekday. while (in_array($end->format('l'), $weekends)) { $end->modify('-1 day')->setTime(23, 59); } // Is the start date after the end date? Might happen if start and end // are on the same weekend (whoops). if ($start > $end) throw new Exception('Start date is AFTER end date!'); // Are the times outside of normal work hours? If so, adjust. $startAdj = clone $start; if ($start < $startAdj->setTime($workStartHour, $workStartMin)) { // Start is earlier; adjust to real start time. $start = $startAdj; } else if ($start > $startAdj->setTime($workEndHour, $workEndMin)) { // Start is after close of that day, move to tomorrow. $start = $startAdj->setTime($workStartHour, $workStartMin)->modify('+1 day'); } $endAdj = clone $end; if ($end > $endAdj->setTime($workEndHour, $workEndMin)) { // End is after; adjust to real end time. $end = $endAdj; } else if ($end < $endAdj->setTime($workStartHour, $workStartMin)) { // End is before start of that day, move to day before. $end = $endAdj->setTime($workEndHour, $workEndMin)->modify('-1 day'); } // Calculate the difference between our modified days. $diff = $start->diff($end); // Go through each day using the original values, so we can check for weekends. $period = new DatePeriod($start, new DateInterval('P1D'), $end); foreach ($period as $day) { // If it's a weekend day, take it out of our total days in the diff. if (in_array($day->format('l'), ['Saturday', 'Sunday'])) $diff->d--; } // Calculate! Days * Hours in a day + hours + minutes converted to hours. $hours = ($diff->d * $workdayHours) + $diff->h + round($diff->i / 60, 2);

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.40.0160.00019.09
8.3.30.0000.01419.16
8.3.20.0080.00020.29
8.3.10.0030.00523.66
8.3.00.0080.00019.12
8.2.170.0100.01022.96
8.2.160.0110.00320.23
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0050.00320.88
8.2.110.0090.00022.17
8.2.100.0080.00417.91
8.2.90.0000.00919.17
8.2.80.0040.00418.00
8.2.70.0030.00517.75
8.2.60.0030.00617.93
8.2.50.0030.00618.07
8.2.40.0050.00321.10
8.2.30.0000.00718.47
8.2.20.0000.00717.84
8.2.10.0040.00418.17
8.2.00.0040.00418.03
8.1.270.0080.00023.97
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00623.88
8.1.230.0070.00419.23
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0080.00317.47
8.1.190.0000.00817.38
8.1.180.0000.00818.10
8.1.170.0000.00918.83
8.1.160.0030.00522.00
8.1.150.0000.00818.86
8.1.140.0040.00417.58
8.1.130.0000.00817.97
8.1.120.0070.00017.73
8.1.110.0070.00017.71
8.1.100.0070.00017.69
8.1.90.0000.00817.68
8.1.80.0030.00517.73
8.1.70.0000.00717.60
8.1.60.0090.00017.74
8.1.50.0000.00817.71
8.1.40.0040.00417.64
8.1.30.0030.00617.73
8.1.20.0040.00417.70
8.1.10.0000.00817.62
8.1.00.0000.00717.62
8.0.300.0000.00818.77
8.0.290.0060.00317.15
8.0.280.0000.00818.56
8.0.270.0030.00317.25
8.0.260.0000.00717.41
8.0.250.0070.00017.19
8.0.240.0040.00417.23
8.0.230.0040.00417.16
8.0.220.0040.00417.00
8.0.210.0070.00017.12
8.0.200.0030.00317.13
8.0.190.0000.00717.07
8.0.180.0040.00417.06
8.0.170.0000.00817.06
8.0.160.0040.00417.23
8.0.150.0040.00416.95
8.0.140.0000.00717.01
8.0.130.0000.00613.57
8.0.120.0000.00817.10
8.0.110.0020.00517.12
8.0.100.0000.00717.01
8.0.90.0000.00817.09
8.0.80.0040.01117.18
8.0.70.0040.00417.13
8.0.60.0040.00417.24
8.0.50.0000.00717.16
8.0.30.0110.01017.16
8.0.20.0150.00917.40
8.0.10.0050.00217.11
8.0.00.0080.01116.95
7.4.330.0030.00315.07
7.4.320.0000.00816.75
7.4.300.0000.00816.67
7.4.290.0000.00716.81
7.4.280.0070.00416.59
7.4.270.0070.00016.70
7.4.260.0100.00016.73
7.4.250.0040.00416.53
7.4.240.0060.00116.67
7.4.230.0040.00416.74
7.4.220.0070.01016.88
7.4.210.0090.00616.65
7.4.200.0040.00416.75
7.4.190.0050.00216.86
7.4.160.0070.01016.61
7.4.150.0040.01317.40
7.4.140.0100.00817.86
7.4.130.0120.00716.69
7.4.120.0100.00816.72
7.4.110.0100.01016.79
7.4.100.0120.00916.94
7.4.90.0120.00616.66
7.4.80.0030.02019.39
7.4.70.0070.01016.78
7.4.60.0140.00616.70
7.4.50.0000.00616.78
7.4.40.0070.01016.75
7.4.30.0090.00916.80
7.4.00.0030.01414.92
7.3.330.0030.00313.41
7.3.320.0070.00013.14
7.3.310.0070.00016.44
7.3.300.0070.00016.43
7.3.290.0100.00716.48
7.3.280.0100.00816.48
7.3.270.0100.00717.40
7.3.260.0070.01016.76
7.3.250.0110.01116.70
7.3.240.0030.01416.50
7.3.230.0100.00716.94
7.3.210.0150.00316.72
7.3.200.0080.00819.39
7.3.190.0130.00316.54
7.3.180.0060.01316.81
7.3.170.0140.00316.60
7.3.160.0030.01516.84
7.3.120.0080.00815.24
7.3.110.0060.00715.13
7.3.100.0080.00015.00
7.3.90.0090.00615.01
7.3.80.0030.00614.96
7.3.70.0040.01114.98
7.3.60.0090.00614.99
7.3.50.0090.00314.88
7.3.40.0030.00814.86
7.3.30.0000.01314.78
7.3.20.0040.01116.97
7.3.10.0070.00716.82
7.3.00.0000.01017.05
7.2.330.0120.00616.72
7.2.320.0120.00616.70
7.2.310.0100.00716.96
7.2.300.0030.01316.95
7.2.290.0130.00316.98
7.2.240.0030.00515.36
7.2.230.0070.00715.36
7.2.220.0060.00615.25
7.2.210.0040.01115.06
7.2.200.0060.00615.38
7.2.190.0000.01615.38
7.2.180.0040.01115.28
7.2.170.0060.01215.03
7.2.160.0070.01015.25
7.2.150.0070.00717.00
7.2.140.0040.01217.16
7.2.130.0060.00917.16
7.2.120.0060.00616.95
7.2.110.0000.01316.97
7.2.100.0040.01116.88
7.2.90.0000.01317.23
7.2.80.0070.01016.84
7.2.70.0100.00717.10
7.2.60.0030.01316.98
7.2.50.0100.00317.14
7.2.40.0090.00617.26
7.2.30.0040.01417.02
7.2.20.0110.00317.20
7.2.10.0000.01817.12
7.2.00.0080.00618.30
7.1.330.0070.00415.86
7.1.320.0040.01116.07
7.1.310.0030.01216.11
7.1.300.0030.01315.79
7.1.290.0090.00916.01
7.1.280.0040.01115.78
7.1.270.0050.00515.96
7.1.260.0060.00915.94
7.1.250.0120.00316.11
7.1.100.0000.01018.32
7.1.70.0050.00317.11
7.1.60.0140.01119.46
7.1.50.0040.01917.24
7.1.00.0070.07022.33
7.0.200.0000.00717.13
7.0.140.0030.07322.09
7.0.60.0100.07719.83
7.0.50.0100.05317.92
7.0.40.0230.06320.04
7.0.30.0270.04020.18
7.0.20.0230.06320.20
7.0.10.0070.08720.12
7.0.00.0030.06020.30
5.6.280.0070.07020.79
5.6.210.0130.07320.58
5.6.200.0070.08318.22
5.6.190.0030.04320.61
5.6.180.0100.06720.41
5.6.170.0100.04720.71
5.6.160.0170.08020.32
5.6.150.0030.07018.21
5.6.140.0070.08718.13
5.6.130.0100.03318.20
5.6.120.0100.08021.03
5.6.110.0130.06721.13
5.6.100.0100.06320.94
5.6.90.0100.08320.98
5.6.80.0070.03720.50
5.5.350.0000.07320.43
5.5.340.0000.04017.98
5.5.330.0100.05320.47
5.5.320.0200.07020.35
5.5.310.0130.04320.17
5.5.300.0070.06717.93
5.5.290.0130.08018.01
5.5.280.0070.04320.67
5.5.270.0100.03720.66
5.5.260.0030.08320.74
5.5.250.0170.06020.55
5.5.240.0030.07020.17
5.4.450.0300.06319.13
5.4.440.0830.05719.48
5.4.430.0700.06719.41
5.4.420.0800.05019.51
5.4.410.0730.05719.13
5.4.400.1130.06018.90
5.4.390.1130.05019.14
5.4.380.0400.05318.66
5.4.370.0370.05318.48
5.4.360.0330.05018.45
5.4.350.0370.05318.58
5.4.340.0430.04718.49
5.4.320.0070.03512.48
5.4.310.0070.04012.47
5.4.300.0070.04912.48
5.4.290.0070.05212.47
5.4.280.0050.03912.37
5.4.270.0110.03812.37
5.4.260.0120.04712.37
5.4.250.0080.05112.37
5.4.240.0080.05212.37
5.4.230.0100.05212.36
5.4.220.0110.05112.36
5.4.210.0100.04512.36
5.4.200.0150.04812.36
5.4.190.0090.04912.36
5.4.180.0090.04812.36
5.4.170.0070.04512.37
5.4.160.0090.04012.37
5.4.150.0080.03612.36
5.4.140.0050.04012.05
5.4.130.0060.04212.04
5.4.120.0100.03411.99
5.4.110.0070.03511.99
5.4.100.0080.03411.99
5.4.90.0070.03611.98
5.4.80.0130.03511.98
5.4.70.0090.04611.98
5.4.60.0070.05011.98
5.4.50.0050.05211.99
5.4.40.0060.05111.97
5.4.30.0060.04911.97
5.4.20.0090.04911.97
5.4.10.0070.04911.97
5.4.00.0110.04811.46
5.3.290.0170.04212.80
5.3.280.0080.05312.71
5.3.270.0080.05512.72
5.3.260.0050.05712.72
5.3.250.0050.05312.72
5.3.240.0050.05212.72
5.3.230.0070.04712.71
5.3.220.0080.04912.68
5.3.210.0090.04912.68
5.3.200.0110.04612.68
5.3.190.0110.04512.68
5.3.180.0070.04912.67
5.3.170.0100.04512.67
5.3.160.0070.04912.67
5.3.150.0100.04812.67
5.3.140.0070.04212.66
5.3.130.0140.03612.66
5.3.120.0040.04612.66
5.3.110.0080.04412.66
5.3.100.0090.04212.11
5.3.90.0090.05112.08
5.3.80.0110.03612.08
5.3.70.0090.03712.07
5.3.60.0060.04812.06
5.3.50.0060.04412.00
5.3.40.0090.04612.00
5.3.30.0090.04311.95
5.3.20.0030.04311.73
5.3.10.0060.03611.70
5.3.00.0040.04511.69
5.2.170.0040.0379.18
5.2.160.0090.0299.18
5.2.150.0050.0359.18
5.2.140.0110.0359.18
5.2.130.0060.0339.14
5.2.120.0050.0479.14
5.2.110.0090.0419.15
5.2.100.0050.0329.14
5.2.90.0080.0399.14
5.2.80.0090.0359.14
5.2.70.0060.0389.14
5.2.60.0080.0389.09
5.2.50.0090.0409.06
5.2.40.0080.0389.04
5.2.30.0070.0329.02
5.2.20.0040.0309.01
5.2.10.0030.0338.93
5.2.00.0030.0368.78
5.1.60.0030.0338.07
5.1.50.0050.0308.06
5.1.40.0070.0248.04
5.1.30.0030.0308.39
5.1.20.0070.0288.42
5.1.10.0060.0348.14
5.1.00.0100.0318.15
5.0.50.0030.0306.62
5.0.40.0060.0266.49
5.0.30.0040.0436.29
5.0.20.0040.0286.29
5.0.10.0030.0296.27
5.0.00.0040.0416.26
4.4.90.0060.0204.78
4.4.80.0050.0224.75
4.4.70.0050.0214.75
4.4.60.0020.0244.75
4.4.50.0080.0194.77
4.4.40.0040.0344.71
4.4.30.0050.0204.76
4.4.20.0050.0224.84
4.4.10.0050.0224.85
4.4.00.0050.0334.76
4.3.110.0020.0254.67
4.3.100.0040.0234.67
4.3.90.0030.0234.64
4.3.80.0030.0334.58
4.3.70.0040.0214.63
4.3.60.0060.0204.63
4.3.50.0040.0224.63
4.3.40.0020.0344.54
4.3.30.0020.0243.31
4.3.20.0020.0243.29
4.3.10.0040.0223.25
4.3.00.0130.0307.36

preferences:
47.62 ms | 400 KiB | 5 Q