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) { $this->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 BusinessDaysCalculator( 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.0090.00916.88
8.3.50.0170.00622.07
8.3.40.0040.01418.87
8.3.30.0070.00719.15
8.3.20.0030.00620.21
8.3.10.0030.00523.48
8.3.00.0080.00019.51
8.2.180.0130.00318.75
8.2.170.0080.00622.96
8.2.160.0140.00020.50
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0000.00922.37
8.2.110.0090.00022.20
8.2.100.0040.00818.03
8.2.90.0050.00319.34
8.2.80.0030.00518.16
8.2.70.0000.01217.88
8.2.60.0060.00318.05
8.2.50.0030.00618.07
8.2.40.0050.00320.01
8.2.30.0000.00818.16
8.2.20.0000.00818.00
8.2.10.0030.00718.32
8.2.00.0030.00718.05
8.1.280.0040.01125.92
8.1.270.0000.00824.00
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00623.95
8.1.230.0040.00819.13
8.1.220.0040.00417.77
8.1.210.0030.00518.77
8.1.200.0030.00717.60
8.1.190.0040.00417.64
8.1.180.0030.00518.10
8.1.170.0030.00618.77
8.1.160.0040.00422.14
8.1.150.0040.00418.93
8.1.140.0080.00017.61
8.1.130.0050.00217.87
8.1.120.0000.00817.75
8.1.110.0080.00017.72
8.1.100.0000.00717.61
8.1.90.0080.00017.73
8.1.80.0000.00817.77
8.1.70.0000.00717.62
8.1.60.0040.00417.68
8.1.50.0030.00517.78
8.1.40.0040.00417.70
8.1.30.0040.00417.82
8.1.20.0000.00817.80
8.1.10.0030.00617.71
8.1.00.0040.00417.64
8.0.300.0040.00818.77
8.0.290.0070.00017.28
8.0.280.0000.00718.61
8.0.270.0030.00317.41
8.0.260.0060.00017.40
8.0.250.0000.00717.21
8.0.240.0000.00817.17
8.0.230.0080.00017.30
8.0.220.0050.00217.23
8.0.210.0000.00817.13
8.0.200.0030.00317.31
8.0.190.0050.00217.19
8.0.180.0070.00017.32
8.0.170.0000.00817.29
8.0.160.0040.00417.22
8.0.150.0070.00017.04
8.0.140.0030.00617.22
8.0.130.0030.00513.59
8.0.120.0040.00417.21
8.0.110.0040.00417.23
8.0.100.0040.00417.06
8.0.90.0040.00417.21
8.0.80.0040.01617.19
8.0.70.0030.00617.06
8.0.60.0000.00817.13
8.0.50.0000.00717.10
8.0.30.0100.01217.38
8.0.20.0120.00617.47
8.0.10.0040.00417.20
8.0.00.0080.01017.09
7.4.330.0000.00515.27
7.4.320.0000.00616.83
7.4.300.0030.00316.72
7.4.290.0000.00716.82
7.4.280.0020.00516.81
7.4.270.0030.00316.64
7.4.260.0080.00016.71
7.4.250.0000.00716.70
7.4.240.0030.00316.76
7.4.230.0030.00316.80
7.4.220.0060.01216.75
7.4.210.0110.00616.74
7.4.200.0060.00316.82
7.4.190.0000.00816.99
7.4.160.0100.00616.66
7.4.150.0130.00417.40
7.4.140.0130.01017.86
7.4.130.0120.00916.69
7.4.120.0090.00816.72
7.4.110.0080.01416.89
7.4.100.0090.00916.85
7.4.90.0160.00016.76
7.4.80.0030.01919.39
7.4.70.0070.01116.94
7.4.60.0140.00516.75
7.4.50.0000.00516.40
7.4.40.0090.00922.77
7.4.30.0150.00316.65
7.4.00.0060.01015.31
7.3.330.0030.00313.40
7.3.320.0030.00213.33
7.3.310.0040.00416.61
7.3.300.0000.00716.45
7.3.290.0030.01716.59
7.3.280.0070.01216.57
7.3.270.0120.00617.40
7.3.260.0080.01516.49
7.3.250.0100.00616.73
7.3.240.0100.00716.88
7.3.230.0160.00616.69
7.3.210.0070.01016.68
7.3.200.0120.00619.39
7.3.190.0060.01316.85
7.3.180.0090.00616.56
7.3.170.0120.00316.71
7.3.160.0130.00316.58
7.3.120.0050.01315.16
7.3.110.0060.00815.01
7.3.100.0000.01315.22
7.3.90.0000.01114.91
7.3.80.0040.00414.94
7.3.70.0000.01314.77
7.3.60.0100.00315.00
7.3.50.0070.00715.14
7.3.40.0120.00615.04
7.3.30.0030.00614.89
7.3.20.0060.00616.87
7.3.10.0060.00616.93
7.3.00.0050.00716.81
7.2.330.0120.00916.80
7.2.320.0070.01016.99
7.2.310.0040.01216.91
7.2.300.0060.01016.93
7.2.290.0030.01617.05
7.2.250.0120.00614.85
7.2.240.0060.01215.24
7.2.230.0100.00715.30
7.2.220.0000.01615.19
7.2.210.0070.01115.20
7.2.200.0070.00715.41
7.2.190.0000.01615.03
7.2.180.0090.00015.21
7.2.170.0070.01015.20
7.2.130.0000.00917.16
7.2.120.0060.00616.86
7.2.110.0070.00717.04
7.2.100.0040.00817.11
7.2.90.0030.01017.17
7.2.80.0040.00817.34
7.2.70.0070.00417.27
7.2.60.0080.00817.10
7.2.50.0060.00617.21
7.2.40.0030.01017.09
7.2.30.0030.01317.01
7.2.20.0090.00317.32
7.2.10.0110.00317.33
7.2.00.0040.00918.38
7.1.330.0060.00616.16
7.1.320.0040.01115.88
7.1.310.0000.01315.98
7.1.300.0070.00716.09
7.1.290.0030.00716.05
7.1.280.0120.00616.02
7.1.270.0070.00715.91
7.1.260.0040.00816.11
7.1.250.0000.01016.15
7.1.200.0110.00016.15
7.1.100.0030.00818.11
7.1.70.0080.00417.21
7.1.60.0060.01919.46
7.1.50.0000.01317.25
7.1.00.0100.07022.36
7.0.200.0030.00516.68
7.0.140.0030.07322.02
7.0.60.0130.06020.00
7.0.50.0170.07317.98
7.0.40.0030.09020.18
7.0.30.0300.07720.34
7.0.20.0270.05020.21
7.0.10.0100.05720.33
7.0.00.0270.06320.05
5.6.280.0100.06720.93
5.6.210.0070.07320.63
5.6.200.0070.08318.25
5.6.190.0100.06020.51
5.6.180.0230.08020.62
5.6.170.0200.04020.44
5.6.160.0000.04720.55
5.6.150.0200.07018.15
5.6.140.0030.04018.24
5.6.130.0030.04018.16
5.6.120.0000.09021.02
5.6.110.0100.07320.99
5.6.100.0070.04021.03
5.6.90.0100.06321.09
5.6.80.0030.07720.36
5.6.70.4500.04320.42
5.5.350.0070.08320.54
5.5.340.0100.07717.93
5.5.330.0070.07720.57
5.5.320.0100.08020.52
5.5.310.0300.05320.24
5.5.300.0070.03717.97
5.5.290.0000.05017.95
5.5.280.0070.04720.98
5.5.270.0070.07320.84
5.5.260.0030.08320.83
5.5.250.0070.08020.79
5.5.240.0170.05020.20
5.4.450.0600.05719.55
5.4.440.0730.06319.59
5.4.430.0830.05019.61
5.4.420.0900.07319.33
5.4.410.0830.05019.57
5.4.400.0670.05719.02
5.4.390.0230.06319.23
5.4.380.0300.06018.86
5.4.370.0430.05018.77
5.4.360.0170.06018.79
5.4.350.0330.05718.79
5.4.340.0200.06718.84
5.4.320.0050.04112.52
5.4.310.0090.04012.52
5.4.300.0110.03312.52
5.4.290.0080.04312.51
5.4.280.0120.03312.38
5.4.270.0050.04112.38
5.4.260.0090.03912.38
5.4.250.0070.04112.38
5.4.240.0090.03712.38
5.4.230.0050.05712.37
5.4.220.0220.08412.38
5.4.210.0130.07012.37
5.4.200.0090.05712.38
5.4.190.0130.05712.37
5.4.180.0110.04812.37
5.4.170.0100.05212.38
5.4.160.0140.03812.38
5.4.150.0070.05312.37
5.4.140.0070.05912.06
5.4.130.0080.05112.05
5.4.120.0070.05312.00
5.4.110.0060.05512.00
5.4.100.0110.04612.00
5.4.90.0220.14012.00
5.4.80.0320.11312.00
5.4.70.0070.04911.99
5.4.60.0070.04011.99
5.4.50.0150.04311.99
5.4.40.0090.04011.98
5.4.30.0060.03811.98
5.4.20.0090.03411.98
5.4.10.0070.03611.98
5.4.00.0060.03711.47
5.3.290.0100.03512.80
5.3.280.0120.03912.71
5.3.270.0100.04012.73
5.3.260.0090.04112.72
5.3.250.0090.03712.72
5.3.240.0070.03912.72
5.3.230.0090.03812.71
5.3.220.0080.03812.68
5.3.210.0090.03912.68
5.3.200.0100.04212.68
5.3.190.0080.04612.68
5.3.180.0130.03812.67
5.3.170.0080.04812.67
5.3.160.0090.05412.67
5.3.150.0130.06112.67
5.3.140.0240.07212.66
5.3.130.0100.05412.66
5.3.120.0120.03812.66
5.3.110.0040.04412.66
5.3.100.0090.03812.12
5.3.90.0090.04412.09
5.3.80.0070.03912.08
5.3.70.0150.03612.07
5.3.60.0070.04712.06
5.3.50.0180.07212.00
5.3.40.0090.04912.01
5.3.30.0110.06411.96
5.3.20.0080.06011.74
5.3.10.0060.03711.71
5.3.00.0080.05411.70
5.2.170.0070.0369.20
5.2.160.0120.0639.20
5.2.150.0150.0469.20
5.2.140.0080.0519.20
5.2.130.0060.0469.16
5.2.120.0080.0429.16
5.2.110.0110.0359.16
5.2.100.0110.0389.16
5.2.90.0090.0409.15
5.2.80.0100.0409.16
5.2.70.0070.0359.15
5.2.60.0040.0349.11
5.2.50.0050.0449.09
5.2.40.0050.0359.05
5.2.30.0070.0289.03
5.2.20.0100.0259.01
5.2.10.0050.0308.93
5.2.00.0060.0318.80
5.1.60.0030.0288.08
5.1.50.0040.0278.09
5.1.40.0110.0438.06
5.1.30.0020.0308.41
5.1.20.0050.0278.44
5.1.10.0070.0238.17
5.1.00.0040.0338.17
5.0.50.0120.0606.63
5.0.40.0060.0276.48
5.0.30.0090.0586.29
5.0.20.0100.0226.26
5.0.10.0050.0276.24
5.0.00.0050.0396.23
4.4.90.0030.0254.78
4.4.80.0090.0484.75
4.4.70.0100.0444.75
4.4.60.0090.0234.75
4.4.50.0180.0604.77
4.4.40.0060.0274.71
4.4.30.0040.0184.76
4.4.20.0100.0444.84
4.4.10.0060.0164.85
4.4.00.0040.0254.75
4.3.110.0040.0174.67
4.3.100.0040.0164.67
4.3.90.0040.0164.63
4.3.80.0040.0254.58
4.3.70.0040.0154.63
4.3.60.0100.0104.63
4.3.50.0050.0214.62
4.3.40.0050.0234.54
4.3.30.0020.0233.28
4.3.20.0050.0233.26
4.3.10.0030.0233.23
4.3.00.0130.03313.47

preferences:
36.64 ms | 401 KiB | 5 Q