3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class MyCalendar { public $free = array(); public $booked = array(); public function __construct($week = 'now') { $start = new DateTime($week); $start->modify('Monday this week midnight'); $end = clone $start; $end->modify('Friday this week midnight'); $interval = new DateInterval('P1D'); foreach (new DatePeriod($start, $interval, $end) as $freeTime) { $this->free[] = $freeTime; } } public function bookAppointment(DateTime $date, $note) { $this->booked[] = array('date' => $date->modify('midnight'), 'note' => $note); } public function checkAvailability() { return array_udiff($this->free, $this->booked, array($this, 'customCompare')); } public function customCompare($free, $booked) { if (is_array($free)) $a = $free['date']; else $a = $free; if (is_array($booked)) $b = $booked['date']; else $b = $booked; if ($a == $b) { return 0; } elseif ($a > $b) { return 1; } else { return -1; } } } // Create a calendar for weekly appointments $myCalendar = new MyCalendar; // Book some appointments for this week $myCalendar->bookAppointment(new DateTime('Monday this week'), "Cleaning GoogleGuy's apartment."); $myCalendar->bookAppointment(new DateTime('Wednesday this week'), "Going on a snowboarding trip."); $myCalendar->bookAppointment(new DateTime('Friday this week'), "Fixing buggy code."); // Check availability of days by comparing $booked dates against $free dates echo "I'm available on the following days this week...\n\n"; foreach ($myCalendar->checkAvailability() as $free) { echo $free->format('l'), "\n"; } echo "\n\n"; echo "I'm busy on the following days this week...\n\n"; foreach ($myCalendar->booked as $booked) { echo $booked['date']->format('l'), ": ", $booked['note'], "\n"; } ?>

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.00618.43
8.3.50.0120.01022.05
8.3.40.0100.01019.13
8.3.30.0070.01418.96
8.3.20.0040.00418.94
8.3.10.0090.00921.06
8.3.00.0120.00421.73
8.2.180.0130.01018.63
8.2.170.0160.00322.96
8.2.160.0140.00720.14
8.2.150.0050.00324.18
8.2.140.0110.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00321.10
8.2.110.0100.00020.69
8.2.100.0030.00917.97
8.2.90.0050.00319.24
8.2.80.0000.00917.97
8.2.70.0080.00017.61
8.2.60.0000.00818.05
8.2.50.0030.00618.07
8.2.40.0040.00418.34
8.2.30.0070.00019.51
8.2.20.0040.00417.86
8.2.10.0080.00018.07
8.2.00.0060.00617.92
8.1.280.0120.00925.92
8.1.270.0030.00523.99
8.1.260.0030.00526.35
8.1.250.0050.00228.09
8.1.240.0030.00622.57
8.1.230.0090.00320.97
8.1.220.0050.00318.77
8.1.210.0080.00019.09
8.1.200.0040.00417.48
8.1.190.0000.00817.76
8.1.180.0050.00318.10
8.1.170.0000.00918.90
8.1.160.0040.00418.99
8.1.150.0040.00418.95
8.1.140.0060.00317.60
8.1.130.0000.00717.97
8.1.120.0040.00417.74
8.1.110.0050.00217.61
8.1.100.0000.00717.70
8.1.90.0040.00417.66
8.1.80.0030.00517.68
8.1.70.0030.00317.76
8.1.60.0040.00417.80
8.1.50.0030.00617.60
8.1.40.0000.00717.70
8.1.30.0040.00417.86
8.1.20.0040.00417.86
8.1.10.0040.00417.81
8.1.00.0040.00417.85
8.0.300.0030.00520.03
8.0.290.0000.00817.18
8.0.280.0030.00318.53
8.0.270.0000.00817.42
8.0.260.0000.00717.15
8.0.250.0040.00417.32
8.0.240.0030.00617.32
8.0.230.0000.00717.18
8.0.220.0070.00017.21
8.0.210.0030.00317.10
8.0.200.0040.00417.16
8.0.190.0000.00717.29
8.0.180.0000.00817.24
8.0.170.0040.00417.29
8.0.160.0050.00317.13
8.0.150.0000.00717.21
8.0.140.0000.00717.20
8.0.130.0030.00313.63
8.0.120.0080.00017.23
8.0.110.0040.00417.29
8.0.100.0000.00717.12
8.0.90.0000.00817.30
8.0.80.0080.00817.16
8.0.70.0040.00417.02
8.0.60.0000.00817.10
8.0.50.0040.00417.31
8.0.30.0080.01317.24
8.0.20.0090.01017.44
8.0.10.0040.00417.41
8.0.00.0120.01017.05
7.4.330.0000.00516.82
7.4.320.0040.00416.72
7.4.300.0030.00316.82
7.4.290.0000.00716.73
7.4.280.0000.00716.79
7.4.270.0080.00016.87
7.4.260.0030.00313.36
7.4.250.0060.00316.73
7.4.240.0000.00716.58
7.4.230.0090.00016.54
7.4.220.0070.01016.65
7.4.210.0080.01016.74
7.4.200.0030.00316.80
7.4.190.0000.00716.74
7.4.160.0100.01416.69
7.4.150.0040.01317.40
7.4.140.0080.00917.86
7.4.130.0120.00516.81
7.4.120.0140.00316.85
7.4.110.0100.00716.76
7.4.100.0060.01116.63
7.4.90.0030.01516.64
7.4.80.0070.01019.39
7.4.70.0060.01216.75
7.4.60.0130.00416.80
7.4.50.0030.00616.97
7.4.40.0030.01022.77
7.4.30.0140.00616.96
7.4.00.0030.01515.29
7.3.330.0030.00413.44
7.3.320.0050.00013.57
7.3.310.0000.00716.63
7.3.300.0000.00716.46
7.3.290.0100.00316.60
7.3.280.0070.00816.57
7.3.270.0090.00917.40
7.3.260.0110.01118.24
7.3.250.0110.00816.72
7.3.240.0140.00316.73
7.3.230.0090.00916.63
7.3.210.0090.00916.80
7.3.200.0100.00716.75
7.3.190.0070.01016.65
7.3.180.0150.00316.81
7.3.170.0140.00616.67
7.3.160.0030.01216.82
7.3.120.0030.00915.07
7.3.10.0070.00716.98
7.3.00.0120.00316.88
7.2.330.0110.00816.73
7.2.320.0060.01616.79
7.2.310.0090.01516.92
7.2.300.0070.01617.04
7.2.290.0030.01516.93
7.2.130.0050.01117.09
7.2.120.0090.00617.16
7.2.110.0130.00517.10
7.2.100.0100.00416.95
7.2.90.0050.01317.13
7.2.80.0070.00917.11
7.2.70.0090.00817.15
7.2.60.0100.00617.14
7.2.50.0110.00517.15
7.2.40.0110.00617.00
7.2.30.0060.00917.04
7.2.20.0080.00817.22
7.2.10.0090.00716.99
7.2.00.0090.00717.93
7.1.250.0080.00715.95
7.1.200.0100.00316.17
7.1.100.0000.00818.38
7.1.70.0000.00817.28
7.1.60.0060.01819.40
7.1.50.0130.01317.32
7.1.00.0000.03722.46
7.0.200.0000.00816.98
7.0.140.0030.07022.21
7.0.70.0030.08721.70
7.0.60.0000.09021.88
7.0.50.0070.07722.04
7.0.40.0030.07720.12
7.0.30.0100.07319.99
7.0.20.0030.07320.08
7.0.10.0070.08020.07
7.0.00.0000.09320.02
5.6.280.0100.06321.11
5.6.220.0100.08320.60
5.6.210.0100.07720.76
5.6.200.0170.07320.96
5.6.190.0070.06321.05
5.6.180.0070.08320.96
5.6.170.0100.07321.19
5.6.160.0100.06321.10
5.6.150.0000.09021.06
5.6.140.0000.08720.99
5.6.130.0070.04021.03
5.6.120.0000.05021.05
5.6.110.0070.04021.12
5.6.100.0030.05321.04
5.6.90.0030.04021.10
5.6.80.0000.04320.51
5.6.70.0030.03720.34
5.6.60.0070.03720.45
5.6.50.0030.03720.36
5.6.40.0000.04020.39
5.6.30.0070.03320.31
5.6.20.0070.03320.28
5.6.10.0030.04020.46
5.6.00.0030.03720.42
5.5.360.0000.06020.49
5.5.350.0030.08320.39
5.5.340.0030.06020.82
5.5.330.0130.07320.88
5.5.320.0100.05720.77
5.5.310.0130.07720.65
5.5.300.0000.05020.77
5.5.290.0000.04320.85
5.5.280.0000.08320.85
5.5.270.0030.04320.76
5.5.260.0030.04320.87
5.5.250.0000.04320.55
5.5.240.0030.03720.32
5.5.230.0070.03720.19
5.5.220.0030.07320.30
5.5.210.0000.04320.20
5.5.200.0000.05020.17
5.5.190.0100.03320.25
5.5.180.0030.04020.20
5.5.160.0070.03320.19
5.5.150.0000.04020.19
5.5.140.0070.03320.18
5.5.130.0000.04020.24
5.5.120.0000.03320.11
5.5.110.0030.04320.25
5.5.100.0030.03720.05
5.5.90.0000.05320.06
5.5.80.0000.03720.16
5.5.70.0000.04020.07
5.5.60.0030.03720.11
5.5.50.0000.03720.15
5.5.40.0000.04320.16
5.5.30.0000.03320.02
5.5.20.0000.03320.05
5.5.10.0000.04720.10
5.5.00.0030.03720.01
5.4.450.0000.05019.23
5.4.440.0000.04019.45
5.4.430.0000.04019.35
5.4.420.0100.03319.35
5.4.410.0030.03719.36
5.4.400.0030.03718.95
5.4.390.0000.04018.91
5.4.380.0070.05718.95
5.4.370.0000.03719.09
5.4.360.0000.04019.05
5.4.350.0030.03718.95
5.4.340.0000.04019.08
5.4.320.0100.07019.10
5.4.310.0030.03019.18
5.4.300.0030.03319.04
5.4.290.0030.03719.09
5.4.280.0030.03019.21
5.4.270.0000.03718.90
5.4.260.0000.04019.13
5.4.250.0000.04319.05
5.4.240.0030.03319.15
5.4.230.0030.03319.02
5.4.220.0070.03319.04
5.4.210.0070.03718.94
5.4.200.0000.03319.04
5.4.190.0000.04319.02
5.4.180.0030.03018.84
5.4.170.0030.04019.02
5.4.160.0030.03719.21
5.4.150.0000.04018.85
5.4.140.0000.06316.49
5.4.130.0000.03716.22
5.4.120.0030.03316.50
5.4.110.0000.06316.49
5.4.100.0000.03716.52
5.4.90.0030.03716.54
5.4.80.0070.07016.39
5.4.70.0030.07316.55
5.4.60.0100.06716.37
5.4.50.0070.07016.38
5.4.40.0000.05316.53
5.4.30.0030.06716.45
5.4.20.0030.05016.49
5.4.10.0000.07716.36
5.4.00.0100.06715.88
5.3.290.0030.04714.66
5.3.280.0000.03714.67
5.3.270.0030.03314.55
5.3.260.0000.03714.74
5.3.250.0000.03714.61
5.3.240.0030.05714.66
5.3.230.0030.03314.62
5.3.220.0030.02714.72
5.3.210.0000.03714.55
5.3.200.0000.08014.55
5.3.190.0000.08014.62
5.3.180.0030.08014.69
5.3.170.0030.04714.54
5.3.160.0070.07714.59
5.3.150.0000.06714.67
5.3.140.0000.08014.50
5.3.130.0030.07714.66
5.3.120.0030.07714.63
5.3.110.0000.04314.55
5.3.100.0000.04714.11
5.3.90.0000.05714.09
5.3.80.0000.08013.92
5.3.70.0030.04014.17
5.3.60.0000.07714.10
5.3.50.0100.06314.08
5.3.40.0100.06313.97
5.3.30.0030.05313.98
5.3.20.0070.06713.59
5.3.10.0030.06013.76
5.3.00.0100.06713.72
5.2.170.0030.03012.20
5.2.160.0000.03312.20
5.2.150.0030.04712.20
5.2.140.0030.06712.20
5.2.130.0000.06712.20
5.2.120.0030.06012.20
5.2.110.0070.05712.20
5.2.100.0030.05712.20
5.2.90.0070.05312.20
5.2.80.0000.07012.20
5.2.70.0070.06012.20
5.2.60.0000.07012.20
5.2.50.0000.06712.20
5.2.40.0070.06012.20
5.2.30.0030.05012.20
5.2.20.0000.06012.20
5.2.10.0070.06012.20
5.2.00.0070.05012.20
5.1.60.0000.03712.20
5.1.50.0030.04712.20
5.1.40.0000.05312.20
5.1.30.0000.05312.20
5.1.20.0030.05712.20
5.1.10.0000.03712.20
5.1.00.0030.05312.20
5.0.50.0000.05012.20
5.0.40.0030.02712.20
5.0.30.0000.06712.20
5.0.20.0000.04712.20
5.0.10.0000.04312.20
5.0.00.0070.06012.20
4.4.90.0000.03712.20
4.4.80.0000.03712.20
4.4.70.0070.02012.20
4.4.60.0000.03012.20
4.4.50.0030.03012.20
4.4.40.0000.05312.20
4.4.30.0000.03712.20
4.4.20.0000.03012.20
4.4.10.0000.02312.20
4.4.00.0000.05312.20
4.3.110.0000.03712.20
4.3.100.0000.03712.20
4.3.90.0000.03712.20
4.3.80.0000.04012.20
4.3.70.0030.02312.20
4.3.60.0000.03712.20
4.3.50.0000.03312.20
4.3.40.0000.05312.20
4.3.30.0000.03012.20
4.3.20.0100.03012.20
4.3.10.0000.04012.20
4.3.00.0030.03312.20

preferences:
49.07 ms | 401 KiB | 5 Q