3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Settings $workStartHour = 9; $workStartMin = 0; $workEndHour = 17; $workEndMin = 30; $workdayHours = 8.5; $weekends = array('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'), array('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)
5.4.350.0100.03313.91
5.4.340.0070.04013.76
5.4.320.0090.04313.39
5.4.310.0050.04413.45
5.4.300.0110.04413.42
5.4.290.0160.03813.42
5.4.280.0080.04313.26
5.4.270.0070.04513.27
5.4.260.0100.06813.26
5.4.250.0070.04513.35
5.4.240.0130.04613.27
5.4.230.0060.04813.35
5.4.220.0070.04713.34
5.4.210.0080.04313.25
5.4.200.0110.04313.34
5.4.190.0100.04413.38
5.4.180.0070.04713.26
5.4.170.0110.04213.28
5.4.160.0110.04313.30
5.4.150.0150.05013.26
5.4.140.0090.04912.95
5.4.130.0040.04313.01
5.4.120.0070.04212.93
5.4.110.0070.04613.02
5.4.100.0080.04212.91
5.4.90.0110.04312.94
5.4.80.0070.04312.93
5.4.70.0110.05112.98
5.4.60.0050.04212.86
5.4.50.0100.04012.92
5.4.40.0100.03912.91
5.4.30.0060.04612.86
5.4.20.0090.04013.00
5.4.10.0080.04212.84
5.4.00.0090.04012.45
5.3.290.0060.05013.74
5.3.280.0090.04613.63
5.3.270.0100.04313.62
5.3.260.0110.04213.63
5.3.250.0130.04013.62
5.3.240.0060.04713.67
5.3.230.0080.04513.58
5.3.220.0090.04513.54
5.3.210.0130.04213.63
5.3.200.0130.04313.59
5.3.190.0080.04313.61
5.3.180.0080.03913.55
5.3.170.0080.04713.62
5.3.160.0060.04413.58
5.3.150.0120.04913.59
5.3.140.0130.04713.52
5.3.130.0140.04813.55
5.3.120.0100.05413.56
5.3.110.0100.05113.57
5.3.100.0070.04513.03
5.3.90.0130.05813.01
5.3.80.0120.07212.99
5.3.70.0130.04513.00
5.3.60.0090.07113.01
5.3.50.0080.04912.89
5.3.40.0110.04812.90
5.3.30.0090.05112.87
5.3.20.0060.04912.67
5.3.10.0120.05212.60
5.3.00.0090.04912.65

preferences:
130 ms | 1386 KiB | 7 Q