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; /** * @param DateTime $startDate Date to start calculations from * @param DateTime[] $holidays Array of holidays, holidays are no conisdered business days. * @param 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($this->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->holidays 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.0070.00716.61
8.3.50.0120.01022.16
8.3.40.0090.00919.09
8.3.30.0040.01119.16
8.3.20.0040.00420.39
8.3.10.0050.00223.52
8.3.00.0030.00619.63
8.2.180.0140.00718.54
8.2.170.0090.00622.96
8.2.160.0070.00720.44
8.2.150.0080.00024.18
8.2.140.0000.00924.66
8.2.130.0080.00026.16
8.2.120.0040.00422.21
8.2.110.0030.00620.50
8.2.100.0090.00318.16
8.2.90.0040.00417.88
8.2.80.0000.00819.20
8.2.70.0050.00317.75
8.2.60.0060.00317.75
8.2.50.0090.00017.88
8.2.40.0040.00419.57
8.2.30.0000.00720.57
8.2.20.0000.00717.85
8.2.10.0030.00618.14
8.2.00.0030.00617.89
8.1.280.0120.00325.92
8.1.270.0040.00424.04
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00323.86
8.1.230.0060.00620.86
8.1.220.0080.00017.89
8.1.210.0050.00318.77
8.1.200.0040.00417.73
8.1.190.0030.00517.48
8.1.180.0060.00318.10
8.1.170.0030.00519.03
8.1.160.0000.00719.21
8.1.150.0080.00018.96
8.1.140.0040.00417.78
8.1.130.0040.00417.89
8.1.120.0040.00417.75
8.1.110.0040.00417.74
8.1.100.0040.00417.72
8.1.90.0000.00817.72
8.1.80.0040.00417.71
8.1.70.0000.00717.68
8.1.60.0090.00017.67
8.1.50.0040.00417.62
8.1.40.0050.00317.75
8.1.30.0040.00417.73
8.1.20.0000.00817.76
8.1.10.0080.00017.73
8.1.00.0000.00817.76
8.0.300.0080.00019.02
8.0.290.0050.00316.84
8.0.280.0060.00318.48
8.0.270.0040.00417.16
8.0.260.0030.00317.40
8.0.250.0000.00717.19
8.0.240.0000.00817.27
8.0.230.0000.00717.34
8.0.220.0000.00717.30
8.0.210.0040.00317.17
8.0.200.0030.00317.29
8.0.190.0040.00417.28
8.0.180.0040.00417.16
8.0.170.0040.00417.30
8.0.160.0000.00717.20
8.0.150.0070.00017.05
8.0.140.0000.00817.18
8.0.130.0030.00513.59
8.0.120.0000.00817.23
8.0.110.0070.00017.14
8.0.100.0030.00517.10
8.0.90.0080.00017.07
8.0.80.0070.00717.16
8.0.70.0040.00417.13
8.0.60.0080.00017.06
8.0.50.0000.00717.14
8.0.30.0110.00817.28
8.0.20.0070.01117.40
8.0.10.0080.00017.25
8.0.00.0080.01217.16
7.4.330.0000.00515.28
7.4.320.0030.00316.86
7.4.300.0030.00316.71
7.4.290.0050.00316.70
7.4.280.0040.00416.71
7.4.270.0050.00316.80
7.4.260.0030.00316.84
7.4.250.0040.00416.73
7.4.240.0030.00416.79
7.4.230.0040.00416.63
7.4.220.0060.01216.74
7.4.210.0080.00916.76
7.4.200.0050.00316.80
7.4.190.0050.00316.81
7.4.160.0070.01116.70
7.4.150.0100.01017.40
7.4.140.0140.00717.86
7.4.130.0110.00616.71
7.4.120.0130.00416.84
7.4.110.0110.00716.82
7.4.100.0130.00616.73
7.4.90.0170.00716.65
7.4.80.0040.01519.39
7.4.70.0130.00416.91
7.4.60.0110.01316.84
7.4.50.0000.00516.59
7.4.40.0080.00822.77
7.4.30.0060.01016.78
7.4.00.0030.01214.96
7.3.330.0050.00013.52
7.3.320.0020.00213.51
7.3.310.0040.00416.56
7.3.300.0030.00316.35
7.3.290.0090.00616.48
7.3.280.0080.01216.47
7.3.270.0100.00717.40
7.3.260.0290.02216.65
7.3.250.0090.00916.73
7.3.240.0120.00916.80
7.3.230.0100.01016.88
7.3.210.0040.01316.80
7.3.200.0060.01519.39
7.3.190.0120.00616.82
7.3.180.0140.00616.64
7.3.170.0090.00916.50
7.3.160.0150.00016.66
7.3.120.0080.00414.91
7.2.330.0050.01417.03
7.2.320.0090.00916.85
7.2.310.0100.01316.89
7.2.300.0000.01616.91
7.2.290.0070.01016.77
7.2.60.0090.00917.04
7.2.00.0000.01119.59
7.1.200.0060.00916.07
7.1.100.0000.01318.18
7.1.70.0040.01217.54
7.1.60.0090.00917.50
7.1.50.0090.00917.21
7.1.40.0070.02116.81
7.1.30.0100.00816.74
7.1.20.0080.01216.84
7.1.10.0050.01416.67
7.1.00.0030.00716.98
7.0.200.0080.00416.80
7.0.190.0080.00516.41
7.0.180.0100.00516.17
7.0.170.0100.00316.61
7.0.160.0060.01316.54
7.0.150.0040.01116.31
7.0.140.0070.00716.34
7.0.130.0100.00316.36
7.0.120.0070.00716.75
7.0.110.0040.00816.39
7.0.100.0000.01916.62
7.0.90.0080.00816.59
7.0.80.0110.00716.54
7.0.70.0090.00616.44
7.0.60.0060.00616.29
7.0.50.0090.00416.50
7.0.40.0080.01014.39
7.0.30.0110.00414.58
7.0.20.0090.00914.47
7.0.10.0050.01014.61
7.0.00.0030.00714.77
5.6.300.0100.03820.77
5.6.290.0070.04520.81
5.6.280.0160.06220.78
5.6.270.0100.07220.85
5.6.260.0060.04621.01
5.6.250.0100.04521.03
5.6.240.0100.05120.91
5.6.230.0070.07320.93
5.6.220.0100.03820.83
5.6.210.0000.04821.03
5.6.200.0070.05320.89
5.6.190.0130.04920.95
5.6.180.0100.04320.97
5.6.170.0000.04620.86
5.6.160.0030.04420.80
5.6.150.0060.05120.87
5.6.140.0000.08420.72
5.6.130.0000.04820.70
5.6.120.0120.03620.94
5.6.110.0100.05520.93
5.6.100.0070.04320.96
5.6.90.0170.04020.92
5.6.80.0060.04820.42
5.6.70.0000.04920.41
5.6.60.0120.04720.22
5.6.50.0160.04020.36
5.6.40.0050.04820.40
5.6.30.0100.04420.33
5.6.20.0040.04720.20
5.6.10.0120.04120.13
5.6.00.0000.04620.39
5.5.380.0060.03717.46
5.5.370.0030.08317.42
5.5.360.0030.04017.54
5.5.350.0090.03817.45
5.5.340.0100.07817.97
5.5.330.0090.03518.11
5.5.320.0000.04917.76
5.5.310.0030.04217.95
5.5.300.0070.03717.71
5.5.290.0200.03718.00
5.5.280.0000.04517.98
5.5.270.0090.04717.97
5.5.260.0000.05518.02
5.5.250.0030.04517.93
5.5.240.0060.03817.52
5.5.230.0150.03617.44
5.5.220.0130.04017.38
5.5.210.0030.04317.55
5.5.200.0100.03817.43
5.5.190.0120.03317.44
5.5.180.0070.03617.48
5.5.160.0160.03517.44
5.5.150.0030.04217.41
5.5.140.0100.06317.21
5.5.130.0030.04017.44
5.5.120.0070.04817.41
5.5.110.0060.05017.42
5.5.100.0030.05416.94
5.5.90.0090.03617.23
5.5.80.0070.03417.09
5.5.70.0130.03117.27
5.5.60.0030.03817.10
5.5.50.0040.04017.24
5.5.40.0070.05917.27
5.5.30.0000.04817.41
5.5.20.0070.03417.33
5.5.10.0000.04216.98
5.5.00.0000.06416.93
5.4.450.0100.03919.22
5.4.440.0030.04719.26
5.4.430.0070.03819.34
5.4.420.0110.04019.26
5.4.410.0070.04919.30
5.4.400.0000.04719.02
5.4.390.0100.03919.20
5.4.380.0000.04419.09
5.4.370.0070.05218.98
5.4.360.0000.05118.96
5.4.350.0130.03319.13
5.4.340.0060.04419.16
5.4.320.0030.04719.13
5.4.310.0070.03618.88
5.4.300.0090.04118.91
5.4.290.0090.03919.20
5.4.280.0070.03918.96
5.4.270.0090.04119.01
5.4.260.0100.04319.20
5.4.250.0030.05518.96
5.4.240.0070.04118.98
5.4.230.0040.03918.96
5.4.220.0000.04218.96
5.4.210.0000.04019.00
5.4.200.0070.05018.88
5.4.190.0090.04419.00
5.4.180.0000.04018.82
5.4.170.0030.03718.93
5.4.160.0030.07719.00
5.4.150.0000.04418.91
5.4.140.0070.03916.55
5.4.130.0090.02816.72
5.4.120.0000.04216.74
5.4.110.0030.04016.75
5.4.100.0060.03416.75
5.4.90.0000.03916.65
5.4.80.0030.03916.68
5.4.70.0030.03616.75
5.4.60.0070.03316.53
5.4.50.0100.03716.57
5.4.40.0000.04016.64
5.4.30.0000.03716.57
5.4.20.0000.03716.63
5.4.10.0000.04516.68
5.4.00.0070.03916.13
5.3.290.0030.04114.95
5.3.280.0090.03414.90
5.3.270.0070.03414.67
5.3.260.0310.04414.66
5.3.250.0070.03614.90
5.3.240.0060.03814.90
5.3.230.0000.04314.91
5.3.220.0000.04714.63
5.3.210.0070.03314.48
5.3.200.0090.03114.86
5.3.190.0000.04014.86
5.3.180.0070.04114.80
5.3.170.0040.03514.93
5.3.160.0040.03614.77
5.3.150.0100.02914.64
5.3.140.0000.04014.76
5.3.130.0000.06814.75
5.3.120.0000.04714.91
5.3.110.0070.03414.58
5.3.100.0030.03614.10
5.3.90.0000.04814.33
5.3.80.0030.04114.21
5.3.70.0030.03614.31
5.3.60.0030.03514.36
5.3.50.0070.05614.17
5.3.40.0030.04014.25
5.3.30.0030.03814.20
5.3.20.0130.02813.92
5.3.10.0030.03613.88
5.3.00.0000.05613.84
5.2.170.0070.02613.70
5.2.160.0060.02713.70
5.2.150.0030.02913.70
5.2.140.0030.02913.70
5.2.130.0030.02713.70
5.2.120.0030.02813.70
5.2.110.0000.03713.70
5.2.100.0030.03313.70
5.2.90.0030.03313.70
5.2.80.0060.04213.70
5.2.70.0030.03513.70
5.2.60.0000.03713.70
5.2.50.0100.03713.70
5.2.40.0000.03313.70
5.2.30.0070.03013.70
5.2.20.0040.02913.70
5.2.10.0000.03813.70
5.2.00.0030.02813.70
5.1.60.0000.02713.70
5.1.50.0000.02813.70
5.1.40.0030.02313.70
5.1.30.0030.03113.70
5.1.20.0030.02613.70
5.1.10.0030.03713.70
5.1.00.0030.02413.70
5.0.50.0000.03013.70
5.0.40.0040.01813.70
5.0.30.0030.03013.70
5.0.20.0000.02413.70
5.0.10.0070.02013.70
5.0.00.0000.04513.70
4.4.90.0030.01613.70
4.4.80.0000.02613.70
4.4.70.0030.01713.70
4.4.60.0000.01613.70
4.4.50.0000.03113.70
4.4.40.0030.02413.70
4.4.30.0000.01813.70
4.4.20.0030.02713.70
4.4.10.0030.03113.70
4.4.00.0030.02313.70
4.3.110.0000.01813.70
4.3.100.0000.02113.70
4.3.90.0000.01713.70
4.3.80.0030.02313.70
4.3.70.0000.01713.70
4.3.60.0030.01313.70
4.3.50.0000.01813.70
4.3.40.0000.02613.70
4.3.30.0000.02313.70
4.3.20.0080.02213.70
4.3.10.0000.01713.70
4.3.00.0000.01813.70

preferences:
42.31 ms | 401 KiB | 5 Q