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($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->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.0070.00716.63
8.3.50.0240.00622.18
8.3.40.0140.00418.96
8.3.30.0060.00919.17
8.3.20.0040.00420.27
8.3.10.0040.00423.71
8.3.00.0030.00619.50
8.2.180.0070.01117.00
8.2.170.0110.00322.96
8.2.160.0100.01020.53
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00422.33
8.2.110.0060.00322.23
8.2.100.0000.01118.16
8.2.90.0040.00419.30
8.2.80.0080.00018.15
8.2.70.0090.00318.00
8.2.60.0040.00418.15
8.2.50.0000.00818.07
8.2.40.0030.00619.88
8.2.30.0100.00018.28
8.2.20.0030.00517.99
8.2.10.0050.00518.13
8.2.00.0070.00218.16
8.1.280.0120.00325.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00324.04
8.1.230.0090.00319.22
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0040.00817.60
8.1.190.0000.00817.65
8.1.180.0000.00818.10
8.1.170.0050.00318.76
8.1.160.0040.00422.17
8.1.150.0070.00018.92
8.1.140.0040.00417.68
8.1.130.0040.00417.93
8.1.120.0000.00717.78
8.1.110.0040.00417.72
8.1.100.0000.00717.76
8.1.90.0000.00817.60
8.1.80.0040.00417.79
8.1.70.0000.00717.70
8.1.60.0040.00417.82
8.1.50.0030.00617.65
8.1.40.0040.00417.77
8.1.30.0000.00917.78
8.1.20.0040.00417.80
8.1.10.0080.00017.75
8.1.00.0080.00017.69
8.0.300.0030.00618.77
8.0.290.0030.00517.14
8.0.280.0030.00318.68
8.0.270.0040.00417.33
8.0.260.0000.00717.39
8.0.250.0030.00317.30
8.0.240.0040.00417.33
8.0.230.0000.00717.23
8.0.220.0000.00717.18
8.0.210.0000.00717.25
8.0.200.0060.00017.18
8.0.190.0040.00417.33
8.0.180.0020.00517.25
8.0.170.0000.00917.18
8.0.160.0000.00717.24
8.0.150.0070.00017.18
8.0.140.0070.00017.19
8.0.130.0030.00313.64
8.0.120.0040.00417.22
8.0.110.0070.00017.25
8.0.100.0040.00417.14
8.0.90.0050.00217.20
8.0.80.0130.00317.16
8.0.70.0080.00017.21
8.0.60.0050.00317.31
8.0.50.0070.00017.07
8.0.30.0100.01317.43
8.0.20.0100.01017.40
8.0.10.0050.00217.41
8.0.00.0170.00517.08
7.4.330.0050.00015.24
7.4.320.0000.00716.81
7.4.300.0030.00316.72
7.4.290.0030.00316.68
7.4.280.0000.00716.77
7.4.270.0000.00716.83
7.4.260.0000.00716.76
7.4.250.0050.00216.61
7.4.240.0040.00416.65
7.4.230.0000.00816.89
7.4.220.0100.01716.89
7.4.210.0070.00716.81
7.4.200.0090.00016.91
7.4.190.0000.00716.59
7.4.160.0060.00916.66
7.4.150.0100.01317.40
7.4.140.0090.01417.86
7.4.130.0120.00516.82
7.4.120.0090.00916.88
7.4.110.0120.00616.65
7.4.100.0060.01516.72
7.4.90.0110.01216.90
7.4.80.0110.01119.39
7.4.70.0060.01016.84
7.4.60.0110.00416.66
7.4.50.0000.00616.63
7.4.40.0080.00822.77
7.4.30.0120.00316.84
7.4.10.0000.01514.88
7.4.00.0090.00915.09
7.3.330.0050.00013.44
7.3.320.0000.00513.65
7.3.310.0000.00716.45
7.3.300.0000.00716.46
7.3.290.0070.01316.60
7.3.280.0080.01016.55
7.3.270.0090.01017.40
7.3.260.0170.00016.60
7.3.250.0140.00616.72
7.3.240.0110.00616.81
7.3.230.0130.00816.87
7.3.210.0110.00516.59
7.3.200.0090.01319.39
7.3.190.0120.00616.71
7.3.180.0070.01016.77
7.3.170.0080.00816.82
7.3.160.0060.01016.88
7.3.130.0030.01215.08
7.3.120.0060.00815.02
7.3.110.0060.01014.93
7.3.100.0040.00715.18
7.3.90.0070.00714.82
7.3.80.0100.00314.90
7.3.70.0000.01015.18
7.3.60.0120.00614.92
7.3.50.0060.01214.94
7.3.40.0060.01015.12
7.3.30.0060.00314.82
7.3.20.0120.00317.06
7.3.10.0060.00916.84
7.3.00.0090.00216.94
7.2.330.0060.01317.12
7.2.320.0070.01117.00
7.2.310.0090.00917.12
7.2.300.0140.00316.87
7.2.290.0190.00316.86
7.2.260.0040.01815.29
7.2.250.0020.01315.09
7.2.240.0110.00415.30
7.2.230.0040.01215.56
7.2.220.0090.00615.38
7.2.210.0060.00914.95
7.2.200.0040.00815.22
7.2.190.0030.00915.54
7.2.180.0150.00415.40
7.2.170.0000.01115.25
7.2.160.0060.01215.41
7.2.150.0080.00817.09
7.2.140.0000.01817.19
7.2.130.0050.00817.12
7.2.120.0050.00717.12
7.2.110.0080.00617.21
7.2.100.0060.00817.10
7.2.90.0050.00817.19
7.2.80.0070.00717.17
7.2.70.0060.00617.16
7.2.60.0040.00817.08
7.2.50.0050.00917.23
7.2.40.0080.00417.09
7.2.30.0060.00617.20
7.2.20.0050.00617.02
7.2.10.0030.01017.20
7.2.00.0040.00817.22
7.1.330.0070.00716.20
7.1.320.0090.00916.07
7.1.310.0030.01016.10
7.1.300.0110.00315.95
7.1.290.0100.00716.00
7.1.280.0030.00815.88
7.1.270.0040.00716.01
7.1.260.0030.00616.13
7.1.250.0060.00815.97
7.1.240.0060.01015.90
7.1.230.0070.01016.11
7.1.220.0000.00916.09
7.1.210.0030.00716.09
7.1.200.0090.00615.94
7.1.190.0060.00615.97
7.1.180.0060.00615.98
7.1.170.0060.00916.16
7.1.160.0080.00416.05
7.1.150.0000.01415.73
7.1.140.0000.00916.05
7.1.130.0090.00616.15
7.1.120.0090.00616.06
7.1.110.0070.01015.98
7.1.100.0030.01316.13
7.1.90.0100.00316.13
7.1.80.0030.01016.04
7.1.70.0070.00716.59
7.1.60.0130.00817.66
7.1.50.0030.01516.69
7.1.40.0000.01415.91
7.1.30.0060.00616.09
7.1.20.0060.00916.05
7.1.10.0040.01416.07
7.1.00.0020.04619.25
7.0.330.0030.01415.62
7.0.320.0000.00915.38
7.0.310.0060.00615.44
7.0.300.0070.00715.32
7.0.290.0030.01015.50
7.0.280.0060.01015.58
7.0.270.0080.00315.78
7.0.260.0030.00715.38
7.0.250.0030.01115.48
7.0.240.0060.00815.57
7.0.230.0060.00615.52
7.0.220.0000.01115.51
7.0.210.0000.01415.52
7.0.200.0070.01016.24
7.0.190.0040.00715.66
7.0.180.0080.00815.75
7.0.170.0100.00315.59
7.0.160.0000.01515.56
7.0.150.0090.00615.54
7.0.140.0020.04418.93
7.0.130.0040.01115.32
7.0.120.0040.01115.45
7.0.110.0080.00615.58
7.0.100.0080.00815.67
7.0.90.0040.00715.62
7.0.80.0080.00815.64
7.0.70.0080.00415.68
7.0.60.0070.04117.82
7.0.50.0050.04016.80
7.0.40.0070.02316.90
7.0.30.0220.03716.85
7.0.20.0120.02516.98
7.0.10.0080.02517.07
7.0.00.0010.02616.97
5.6.400.0030.01014.72
5.6.390.0030.01414.46
5.6.380.0000.01314.39
5.6.370.0070.00314.49
5.6.360.0040.01114.69
5.6.350.0100.00314.90
5.6.340.0060.00914.70
5.6.330.0000.01314.28
5.6.320.0100.00714.49
5.6.310.0070.00414.36
5.6.300.0090.00614.45
5.6.290.0070.00714.62
5.6.280.0020.04317.80
5.6.270.0060.00614.64
5.6.260.0100.00714.54
5.6.250.0070.01014.41
5.6.240.0090.00614.48
5.6.230.0120.00914.62
5.6.220.0030.01314.65
5.6.210.0070.04417.54
5.6.200.0100.04016.48
5.6.190.0130.04317.71
5.6.180.0060.04117.54
5.6.170.0150.03717.57
5.6.160.0030.04817.59
5.6.150.0090.02516.37
5.6.140.0020.02816.40
5.6.130.0050.04416.40
5.6.120.0090.04117.73
5.6.110.0070.04217.74
5.6.100.0070.04517.75
5.6.90.0070.02117.76
5.6.80.0080.03917.49
5.6.70.0000.01514.70
5.6.60.0060.00914.36
5.6.50.0110.00714.45
5.6.40.0070.00714.50
5.6.30.0040.00814.47
5.6.20.0060.00614.59
5.6.10.0030.00714.75
5.6.00.0070.00714.38
5.5.380.0080.00614.66
5.5.370.0000.02014.58
5.5.360.0030.00614.61
5.5.350.0070.02417.38
5.5.340.0110.03816.28
5.5.330.0050.03517.39
5.5.320.0150.04517.59
5.5.310.0160.02717.50
5.5.300.0090.03916.21
5.5.290.0050.02016.23
5.5.280.0090.04217.51
5.5.270.0000.03817.69
5.5.260.0080.03717.81
5.5.250.0070.03517.27
5.5.240.0060.01817.09
5.5.230.0030.01014.27
5.5.220.0070.01014.49
5.5.210.0070.01114.56
5.5.200.0140.00014.46
5.5.190.0000.01414.50
5.5.180.0030.01414.43
5.5.170.0070.00314.62
5.5.160.0070.00714.61
5.5.150.0080.00414.26
5.5.140.0070.00714.66
5.5.130.0100.00714.58
5.5.120.0070.00714.65
5.5.110.0030.00914.54
5.5.100.0030.01014.38
5.5.90.0090.00614.50
5.5.80.0080.00614.43
5.5.70.0100.00314.47
5.5.60.0030.00814.55
5.5.50.0080.00414.45
5.5.40.0070.00414.73
5.5.30.0080.00414.34
5.5.20.0000.01214.22
5.5.10.0070.00714.62
5.5.00.0040.00814.36
5.4.450.0110.04315.88
5.4.440.0430.03115.88
5.4.430.0320.02915.95
5.4.420.0320.02515.95
5.4.410.0320.03715.77
5.4.400.0420.03915.79
5.4.390.0380.03215.77
5.4.380.0150.03515.38
5.4.370.0200.02615.50
5.4.360.0150.02915.41
5.4.350.0250.03215.54
5.4.340.0200.03215.54
5.4.330.0030.00712.29
5.4.320.0070.02312.40
5.4.310.0070.02512.40
5.4.300.0060.02112.40
5.4.290.0040.02412.40
5.4.280.0060.02012.33
5.4.270.0060.02812.34
5.4.260.0040.03812.33
5.4.250.0070.02912.33
5.4.240.0100.02412.34
5.4.230.0070.02812.33
5.4.220.0090.02112.33
5.4.210.0070.03612.33
5.4.200.0090.03312.33
5.4.190.0100.02112.33
5.4.180.0060.02412.33
5.4.170.0080.01912.34
5.4.160.0080.01812.33
5.4.150.0060.02212.33
5.4.140.0020.02712.17
5.4.130.0040.02412.17
5.4.120.0060.02412.14
5.4.110.0080.02212.14
5.4.100.0090.02512.14
5.4.90.0090.02912.14
5.4.80.0040.03312.14
5.4.70.0080.02912.14
5.4.60.0080.02712.14
5.4.50.0050.02612.14
5.4.40.0060.02912.13
5.4.30.0060.02912.13
5.4.20.0040.02412.13
5.4.10.0070.02912.13
5.4.00.0050.02311.88
5.3.290.0080.02012.54
5.3.280.0100.03812.50
5.3.270.0040.02612.51
5.3.260.0070.01912.51
5.3.250.0060.01912.50
5.3.240.0060.02112.50
5.3.230.0070.02112.50
5.3.220.0070.02412.49
5.3.210.0080.02312.49
5.3.200.0040.02712.48
5.3.190.0060.02312.48
5.3.180.0050.02912.48
5.3.170.0100.02312.48
5.3.160.0070.03512.48
5.3.150.0090.03612.48
5.3.140.0090.02012.47
5.3.130.0060.02412.47
5.3.120.0080.02712.47
5.3.110.0050.02612.47
5.3.100.0030.02512.21
5.3.90.0070.02212.19
5.3.80.0100.03712.18
5.3.70.0080.03412.18
5.3.60.0080.03312.17
5.3.50.0060.03112.15
5.3.40.0070.02712.15
5.3.30.0050.02612.13
5.3.20.0060.02112.02
5.3.10.0040.02312.00
5.3.00.0030.02512.00
5.2.170.0050.0349.20
5.2.160.0060.0349.20
5.2.150.0040.0469.20
5.2.140.0080.0439.20
5.2.130.0080.0439.15
5.2.120.0030.0369.16
5.2.110.0060.0329.16
5.2.100.0090.0299.16
5.2.90.0140.0399.15
5.2.80.0090.0449.15
5.2.70.0060.0469.15
5.2.60.0080.0429.11
5.2.50.0080.0439.09
5.2.40.0050.0359.06
5.2.30.0060.0339.03
5.2.20.0140.0289.02
5.2.10.0080.0318.93
5.2.00.0070.0418.79
5.1.60.0060.0388.09
5.1.50.0120.0358.09
5.1.40.0110.0518.06
5.1.30.0250.0528.41
5.1.20.0100.0378.44
5.1.10.0040.0318.17
5.1.00.0090.0248.16
5.0.50.0090.0246.62
5.0.40.0040.0226.49
5.0.30.0050.0496.29
5.0.20.0040.0226.26
5.0.10.0060.0206.24
5.0.00.0040.0346.23
4.4.90.0110.0624.78
4.4.80.0040.0184.75
4.4.70.0020.0234.75
4.4.60.0030.0214.75
4.4.50.0050.0204.77
4.4.40.0030.0364.71
4.4.30.0040.0214.76
4.4.20.0040.0224.85
4.4.10.0030.0234.85
4.4.00.0080.0294.76
4.3.110.0010.0204.67
4.3.100.0040.0164.66
4.3.90.0040.0144.63
4.3.80.0020.0264.59
4.3.70.0030.0154.63
4.3.60.0030.0224.63
4.3.50.0030.0154.63
4.3.40.0040.0314.54
4.3.30.0020.0223.28
4.3.20.0020.0223.27
4.3.10.0010.0173.23
4.3.00.0230.01313.47

preferences:
42.72 ms | 401 KiB | 5 Q