3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BusinessDaysCalculator { const MONDAY = 1; const TUESDAY = 2; const WEDNESDAY = 3; const THURSDAY = 4; const FRIDAY = 5; const SATURDAY = 6; const SUNDAY = 7; /** * DateTime $startDate Date to start calculations from * DateTime[] $holidays Array of holidays, holidays are no conisdered business days. * int[] $nonBusinessDays Array of days of the week which are not business days. */ public function __construct(DateTime $startDate, array $holidays, array $nonBusinessDays) { $this->date = $startDate; $this->holidays = $holidays; $this->nonBusinessDays = $nonBusinessDays; } public function addBusinessDays($howManyDays) { $i = 0; while ($i < $howManyDays) { $date->modify("+1 day"); if ($this->isBusinessDay($date)) { $i++; } } } public function getDate() { return $this->date; } private function isBusinessDay(DateTime $date) { if (in_array((int)$date->format('N'), $this->nonBusinessDays)) { return false; //Date is a nonBusinessDay. } foreach ($this->nonBusinessDays as $day) { if ($date->format('Y-m-d') == $day->format('Y-m-d')) { return false; //Date is a holiday. } } return true; //Date is a business day. } } $calculator = new BusinessDayCalculator( [new DateTime()], // Today [new DateTime("2014-06-01"), new DateTime("2014-06-02")], [BusinessDaysCalculator::SATURDAY, BusinessDaysCalculator::FRIDAY] ); $calculator->addBusinessDays(3); // Add three business days var_dump($calculator->getDate());

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.0040.01116.63
8.3.50.0080.01322.06
8.3.40.0110.00718.82
8.3.30.0080.00619.21
8.3.20.0000.00820.21
8.3.10.0080.00023.61
8.3.00.0080.00019.50
8.2.180.0150.00418.29
8.2.170.0080.00822.96
8.2.160.0120.00320.38
8.2.150.0030.00524.18
8.2.140.0050.00324.66
8.2.130.0000.00926.16
8.2.120.0040.00422.08
8.2.110.0060.00322.07
8.2.100.0120.00017.91
8.2.90.0000.00819.09
8.2.80.0000.00817.97
8.2.70.0090.00017.46
8.2.60.0000.00817.88
8.2.50.0060.00318.07
8.2.40.0060.00319.62
8.2.30.0040.00417.90
8.2.20.0000.00817.64
8.2.10.0000.01017.91
8.2.00.0070.00317.59
8.1.280.0030.01025.92
8.1.270.0050.00324.02
8.1.260.0070.00326.35
8.1.250.0080.00028.09
8.1.240.0060.00323.97
8.1.230.0090.00317.42
8.1.220.0050.00317.74
8.1.210.0000.00818.77
8.1.200.0030.00617.10
8.1.190.0030.00617.41
8.1.180.0030.00518.10
8.1.170.0050.00318.52
8.1.160.0070.00021.95
8.1.150.0040.00418.52
8.1.140.0000.00717.23
8.1.130.0070.00017.76
8.1.120.0030.00517.23
8.1.110.0040.00417.23
8.1.100.0000.00717.23
8.1.90.0000.00717.33
8.1.80.0070.00017.33
8.1.70.0000.00817.34
8.1.60.0070.00017.37
8.1.50.0000.00817.54
8.1.40.0000.00817.36
8.1.30.0030.00517.59
8.1.20.0020.00517.53
8.1.10.0050.00217.47
8.1.00.0040.00417.31
8.0.300.0040.00418.77
8.0.290.0000.00816.63
8.0.280.0030.00318.31
8.0.270.0030.00317.27
8.0.260.0030.00317.16
8.0.250.0030.00316.94
8.0.240.0030.00316.88
8.0.230.0030.00316.84
8.0.220.0000.00716.73
8.0.210.0000.00716.93
8.0.200.0030.00317.00
8.0.190.0000.00817.00
8.0.180.0040.00416.97
8.0.170.0000.00816.96
8.0.160.0060.00316.96
8.0.150.0040.00416.73
8.0.140.0070.00016.89
8.0.130.0030.00313.23
8.0.120.0040.00416.85
8.0.110.0040.00416.94
8.0.100.0050.00316.85
8.0.90.0080.00016.88
8.0.80.0040.01116.94
8.0.70.0070.00016.68
8.0.60.0040.00416.91
8.0.50.0000.00716.84
8.0.30.0130.00617.07
8.0.20.0090.01217.40
8.0.10.0000.00716.92
8.0.00.0100.01016.62
7.4.330.0030.00315.00
7.4.320.0030.00316.37
7.4.300.0060.00016.52
7.4.290.0000.00816.37
7.4.280.0040.00416.36
7.4.270.0040.00416.48
7.4.260.0030.00316.45
7.4.250.0040.00416.55
7.4.240.0030.00316.51
7.4.230.0070.00016.62
7.4.220.0040.01416.36
7.4.210.0100.00516.56
7.4.200.0040.00416.55
7.4.190.0030.00316.68
7.4.160.0060.00916.73
7.4.150.0080.01517.40
7.4.140.0140.00517.86
7.4.130.0090.01016.56
7.4.120.0070.01216.54
7.4.110.0030.01916.55
7.4.100.0090.00916.51
7.4.90.0120.00616.35
7.4.80.0070.01019.39
7.4.70.0060.01216.28
7.4.60.0120.01216.61
7.4.50.0000.00716.47
7.4.40.0040.00822.77
7.4.30.0000.01616.55
7.4.00.0030.01214.90
7.3.330.0000.00513.29
7.3.320.0020.00213.18
7.3.310.0040.00416.37
7.3.300.0060.00016.31
7.3.290.0030.01216.31
7.3.280.0120.00716.34
7.3.270.0110.00617.40
7.3.260.0150.00916.58
7.3.250.0050.01216.37
7.3.240.0120.00616.32
7.3.230.0080.00816.39
7.3.210.0060.01116.27
7.3.200.0090.00919.39
7.3.190.0070.01116.30
7.3.180.0070.01016.52
7.3.170.0060.01016.61
7.3.160.0070.01016.29
7.3.120.0090.00615.11
7.3.10.0070.00816.50
7.3.00.0070.01116.45
7.2.330.0070.01016.36
7.2.320.0060.01316.59
7.2.310.0130.00316.56
7.2.300.0150.00916.64
7.2.290.0060.01116.34
7.2.130.0100.00516.71
7.2.120.0120.00616.38
7.2.110.0080.00316.55
7.2.100.0080.01016.48
7.2.90.0070.00816.62
7.2.80.0130.00516.48
7.2.70.0140.01216.79
7.2.60.0070.00816.53
7.2.50.0110.00816.60
7.2.40.0110.00816.44
7.2.30.0130.00616.55
7.2.20.0080.01116.53
7.2.10.0120.00916.47
7.2.00.0050.01317.52
7.1.250.0060.00515.48
7.1.200.0030.00615.70
7.1.100.0040.00717.46
7.1.70.0060.00316.98
7.1.60.0070.01819.46
7.1.50.0180.01834.46
7.1.00.0030.07322.54
7.0.200.0040.00416.34
7.0.140.0030.07322.05
7.0.60.0100.04320.04
7.0.50.0100.06717.89
7.0.40.0200.07320.16
7.0.30.0300.06320.24
7.0.20.0300.07720.12
7.0.10.0030.08020.23
7.0.00.0000.04320.17
5.6.280.0000.07721.01
5.6.210.0030.04020.66
5.6.200.0070.08318.23
5.6.190.0030.04720.41
5.6.180.0270.03320.61
5.6.170.0230.04720.47
5.6.160.0030.07720.46
5.6.150.0070.08018.16
5.6.140.0070.06018.28
5.6.130.0130.03018.23
5.6.120.0200.07321.00
5.6.110.0200.06721.05
5.6.100.0000.07721.05
5.6.90.0100.08321.11
5.6.80.0170.07720.39
5.6.70.3170.03720.37
5.5.350.0130.06720.42
5.5.340.0200.06718.08
5.5.330.0030.09020.36
5.5.320.0000.04720.38
5.5.310.0430.05020.27
5.5.300.0000.06317.95
5.5.290.0130.05718.06
5.5.280.0100.05320.91
5.5.270.0070.07720.97
5.5.260.0070.08020.94
5.5.250.0070.04320.67
5.5.240.0170.03320.05
5.4.450.0230.07719.54
5.4.440.0800.06319.56
5.4.430.1000.06719.63
5.4.420.0170.04719.16
5.4.410.0700.05719.45
5.4.400.0770.05719.14
5.4.390.0800.05318.84
5.4.380.0430.07018.77
5.4.370.0270.05018.83
5.4.360.0270.05318.84
5.4.350.0370.05018.79
5.4.340.0370.06018.84
5.4.320.0050.04712.51
5.4.310.0080.04112.51
5.4.300.0090.03812.51
5.4.290.0070.04312.51
5.4.280.0070.04012.38
5.4.270.0100.03312.38
5.4.260.0090.03812.38
5.4.250.0090.04112.38
5.4.240.0070.03612.38
5.4.230.0040.04212.37
5.4.220.0060.03712.37
5.4.210.0070.03612.37
5.4.200.0040.04112.37
5.4.190.0060.05612.37
5.4.180.0080.04112.36
5.4.170.0090.03812.38
5.4.160.0110.03712.37
5.4.150.0060.04012.38
5.4.140.0060.03812.05
5.4.130.0080.03812.04
5.4.120.0060.05812.00
5.4.110.0060.06012.00
5.4.100.0090.03812.00
5.4.90.0120.04812.00
5.4.80.0080.04012.00
5.4.70.0080.03611.99
5.4.60.0060.04012.00
5.4.50.0090.03411.99
5.4.40.0050.03711.98
5.4.30.0070.03711.98
5.4.20.0100.04111.97
5.4.10.0050.03711.98
5.4.00.0090.03511.47
5.3.290.0040.04512.80
5.3.280.0100.03712.71
5.3.270.0070.04212.73
5.3.260.0080.04212.72
5.3.250.0030.04312.72
5.3.240.0070.03912.72
5.3.230.0070.05512.70
5.3.220.0070.05512.68
5.3.210.0060.04112.68
5.3.200.0090.03412.68
5.3.190.0080.05012.67
5.3.180.0100.03412.67
5.3.170.0080.03612.67
5.3.160.0070.03712.68
5.3.150.0070.03812.68
5.3.140.0080.03812.66
5.3.130.0080.04412.66
5.3.120.0050.04312.66
5.3.110.0080.04212.66
5.3.100.0040.04412.12
5.3.90.0060.04112.09
5.3.80.0070.03812.09
5.3.70.0100.04812.08
5.3.60.0050.04812.06
5.3.50.0030.04012.00
5.3.40.0120.03312.00
5.3.30.0040.03911.96
5.3.20.0090.03611.74
5.3.10.0090.03511.71
5.3.00.0080.05011.70
5.2.170.0120.0469.20
5.2.160.0070.0469.20
5.2.150.0090.0499.20
5.2.140.0080.0369.20
5.2.130.0070.0389.16
5.2.120.0080.0279.16
5.2.110.0090.0279.16
5.2.100.0060.0409.16
5.2.90.0070.0439.15
5.2.80.0080.0429.16
5.2.70.0090.0419.15
5.2.60.0080.0439.11
5.2.50.0090.0339.08
5.2.40.0100.0289.06
5.2.30.0080.0339.03
5.2.20.0050.0359.02
5.2.10.0120.0558.93
5.2.00.0080.0448.80
5.1.60.0060.0348.09
5.1.50.0070.0238.09
5.1.40.0060.0258.07
5.1.30.0050.0378.41
5.1.20.0070.0398.44
5.1.10.0100.0328.16
5.1.00.0040.0338.16
5.0.50.0040.0296.62
5.0.40.0070.0276.48
5.0.30.0030.0456.29
5.0.20.0050.0186.26
5.0.10.0080.0176.24
5.0.00.0020.0346.23
4.4.90.0040.0154.78
4.4.80.0020.0164.76
4.4.70.0000.0194.75
4.4.60.0040.0144.76
4.4.50.0030.0174.77
4.4.40.0040.0254.71
4.4.30.0020.0174.76
4.4.20.0030.0164.84
4.4.10.0010.0184.84
4.4.00.0080.0194.76
4.3.110.0050.0154.67
4.3.100.0020.0174.66
4.3.90.0040.0144.63
4.3.80.0030.0304.58
4.3.70.0040.0194.63
4.3.60.0030.0144.62
4.3.50.0050.0144.63
4.3.40.0020.0254.54
4.3.30.0020.0173.29
4.3.20.0040.0153.27
4.3.10.0010.0173.23
4.3.00.0070.01313.47

preferences:
44.47 ms | 401 KiB | 5 Q