3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getOverlapDays($ranges) { $overlapDays = 0; // no overlap by default $range = $ranges[0]; // starting with the first element of range array $itemsCnt = count($ranges); for ($id = 1; $id < $itemsCnt; $id++) { $start1 = is_a($range["start"], "DateTime") ? $range["start"] : new DateTime($range["start"]); $end1 = is_a($range["end"], "DateTime") ? $range["end"] : new DateTime($range["end"]); $start2 = is_a($ranges[$id]["start"], "DateTime") ? $ranges[$id]["start"] : new DateTime($ranges[$id]["start"]); $end2 = is_a($ranges[$id]["end"], "DateTime") ? $ranges[$id]["end"] : new DateTime($ranges[$id]["end"]); if ($start1 <= $end2 && $end1 >= $start2) { // if the dates overlap return min($end1, $end2)->diff(max($start2, $start1))->days + 1; // return how many days overlap } else { $range = [ "start" => $start1 > $start2 ? $start1 : $start2, "end" => $end1 > $end2 ? $end1 : $end2 ]; } } return $overlapDays; } // example $ranges = array( array('start' => '2013-12-31', 'end' => '2013-12-31'), array('start' => '2014-01-01', 'end' => '2014-01-01') ); echo getOverlapDays($ranges);

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.0190.00616.49
8.3.50.0120.01022.94
8.3.40.0150.00319.09
8.3.30.0100.00719.27
8.3.20.0040.00420.19
8.3.10.0060.00321.84
8.3.00.0000.00817.93
8.2.180.0070.00718.29
8.2.170.0090.00622.96
8.2.160.0100.01022.13
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.01
8.2.110.0000.00922.26
8.2.100.0090.00318.03
8.2.90.0030.00518.03
8.2.80.0030.00517.97
8.2.70.0030.00517.74
8.2.60.0030.00618.18
8.2.50.0040.00418.07
8.2.40.0060.00318.47
8.2.30.0000.00718.09
8.2.20.0030.00517.96
8.2.10.0040.00418.12
8.2.00.0080.00017.96
8.1.280.0090.00625.92
8.1.270.0060.00322.18
8.1.260.0090.00926.35
8.1.250.0000.00828.09
8.1.240.0090.00022.60
8.1.230.0080.00420.91
8.1.220.0050.00317.86
8.1.210.0040.00418.99
8.1.200.0100.00017.60
8.1.190.0040.00417.63
8.1.180.0040.00420.25
8.1.170.0030.00618.60
8.1.160.0000.00722.07
8.1.150.0040.00418.86
8.1.140.0000.00717.67
8.1.130.0030.00317.93
8.1.120.0000.00817.66
8.1.110.0020.00517.69
8.1.100.0030.00317.63
8.1.90.0000.00717.73
8.1.80.0080.00017.69
8.1.70.0030.00517.52
8.1.60.0080.00017.77
8.1.50.0040.00417.53
8.1.40.0040.00417.67
8.1.30.0060.00317.86
8.1.20.0040.00417.78
8.1.10.0080.00017.63
8.1.00.0000.01017.69
8.0.300.0060.00319.90
8.0.290.0040.00417.30
8.0.280.0030.00318.41
8.0.270.0030.00417.27
8.0.260.0000.00717.36
8.0.250.0000.00617.09
8.0.240.0000.00617.18
8.0.230.0070.00017.07
8.0.220.0070.00017.07
8.0.210.0000.00717.10
8.0.200.0030.00317.08
8.0.190.0000.00717.06
8.0.180.0050.00317.16
8.0.170.0000.00817.13
8.0.160.0040.00417.23
8.0.150.0040.00416.96
8.0.140.0040.00417.01
8.0.130.0030.00313.47
8.0.120.0080.00017.13
8.0.110.0080.00017.17
8.0.100.0030.00517.00
8.0.90.0040.00416.99
8.0.80.0100.00717.02
8.0.70.0040.00416.98
8.0.60.0050.00217.14
8.0.50.0050.00316.90
8.0.30.0090.00917.33
8.0.20.0050.01417.42
8.0.10.0070.00017.25
8.0.00.0050.01316.90
7.4.330.0020.00215.06
7.4.320.0060.00016.67
7.4.300.0060.00016.78
7.4.290.0040.00416.75
7.4.280.0040.00416.79
7.4.270.0030.00316.68
7.4.260.0030.00316.77
7.4.250.0050.00216.68
7.4.240.0040.00416.69
7.4.230.0070.00016.76
7.4.220.0130.00616.80
7.4.210.0060.00816.66
7.4.200.0030.00316.56
7.4.160.0030.01316.67
7.4.150.0060.01217.40
7.4.140.0090.00917.86
7.4.130.0140.00616.75
7.4.120.0050.01216.70
7.4.110.0100.01416.63
7.4.100.0100.00816.79
7.4.90.0070.01016.79
7.4.80.0060.01519.39
7.4.70.0130.00916.77
7.4.60.0140.00316.77
7.4.50.0040.00016.79
7.4.40.0100.00716.60
7.4.30.0100.00716.69
7.4.10.0070.01416.67
7.4.00.0050.01315.80
7.3.330.0000.00613.33
7.3.320.0000.00713.49
7.3.310.0000.00716.40
7.3.300.0000.00616.40
7.3.290.0070.00916.48
7.3.280.0070.01016.50
7.3.270.0070.01017.40
7.3.260.0110.01116.55
7.3.250.0130.00816.69
7.3.240.0130.00316.79
7.3.230.0100.00716.65
7.3.210.0100.01316.59
7.3.200.0150.00619.39
7.3.190.0080.01216.51
7.3.180.0070.01316.67
7.3.170.0050.01116.75
7.3.160.0160.00316.69
7.3.130.0000.01916.59
7.3.120.0030.00916.68
7.3.110.0040.00816.66
7.3.100.0090.00316.56
7.3.90.0070.00716.62
7.3.80.0060.00616.56
7.3.70.0100.00616.57
7.3.60.0040.00416.59
7.3.50.0030.01216.50
7.3.40.0060.00816.52
7.3.30.0040.01116.53
7.3.20.0090.00618.38
7.3.10.0120.00918.23
7.3.00.0040.01118.22
7.2.330.0150.00316.93
7.2.320.0060.01216.96
7.2.310.0100.00716.68
7.2.300.0110.00716.80
7.2.290.0110.01117.00
7.2.260.0070.01416.87
7.2.250.0110.00716.75
7.2.240.0040.01116.91
7.2.230.0080.00416.82
7.2.220.0040.01117.02
7.2.210.0030.00917.04
7.2.200.0070.00316.80
7.2.190.0040.01116.68
7.2.180.0120.00316.68
7.2.170.0060.00916.75
7.2.160.0070.00716.71
7.2.150.0070.01118.63
7.2.140.0030.01918.61
7.2.130.0030.01018.61
7.2.120.0180.00418.59
7.2.110.0070.01118.56
7.2.100.0130.00718.57
7.2.90.0100.00618.63
7.2.80.0030.01218.67
7.2.70.0030.01118.39
7.2.60.0070.00718.56
7.2.50.0110.01118.50
7.2.40.0090.01218.55
7.2.30.0090.00618.75
7.2.20.0040.01118.66
7.2.10.0030.01018.61
7.2.00.0110.00318.46
7.1.330.0030.01417.62
7.1.320.0030.00617.40
7.1.310.0060.01317.52
7.1.300.0100.00317.61
7.1.290.0080.00417.53
7.1.280.0070.00717.38
7.1.270.0030.00617.50
7.1.260.0060.00917.61
7.1.250.0060.00617.57
7.1.240.0040.01217.48
7.1.230.0090.00617.37
7.1.220.0060.01017.40
7.1.210.0060.00917.59
7.1.200.0030.00617.50
7.1.190.0060.00317.49
7.1.180.0040.01217.53
7.1.170.0000.01517.43
7.1.160.0120.00017.45
7.1.150.0100.00017.55
7.1.140.0030.00717.57
7.1.130.0000.01117.50
7.1.120.0060.00317.55
7.1.110.0090.00617.61
7.1.100.0070.00717.45
7.1.90.0030.01017.36
7.1.80.0060.00617.64
7.1.70.0050.00617.42
7.1.60.0120.00718.50
7.1.50.0100.00817.18
7.1.40.0030.01217.43
7.1.30.0050.00517.59
7.1.20.0030.00617.59
7.1.10.0090.00617.66
7.1.00.0050.04220.03
7.0.330.0070.00717.15
7.0.320.0060.00917.22
7.0.310.0060.00917.10
7.0.300.0060.00616.94
7.0.290.0030.01016.97
7.0.280.0070.00717.18
7.0.270.0070.00717.12
7.0.260.0060.00617.07
7.0.250.0070.00717.13
7.0.240.0060.00817.10
7.0.230.0030.00917.00
7.0.220.0040.00817.13
7.0.210.0030.01017.27
7.0.200.0060.00517.02
7.0.190.0060.01017.29
7.0.180.0100.00317.23
7.0.170.0090.00317.18
7.0.160.0000.01116.99
7.0.150.0080.00517.07
7.0.140.0020.02419.58
7.0.130.0060.00917.09
7.0.120.0040.00817.29
7.0.110.0000.01517.19
7.0.100.0100.01017.32
7.0.90.0120.00617.37
7.0.80.0000.00917.13
7.0.70.0070.01017.11
7.0.60.0030.03918.60
7.0.50.0050.03517.54
7.0.40.0050.02317.78
7.0.30.0200.03517.73
7.0.20.0170.03817.67
7.0.10.0100.04117.64
7.0.00.0070.02517.76
5.6.400.0060.00916.36
5.6.390.0040.01116.06
5.6.380.0110.00416.25
5.6.370.0100.00316.31
5.6.360.0070.00415.95
5.6.350.0000.01216.27
5.6.340.0100.00316.00
5.6.330.0060.00316.25
5.6.320.0060.00916.39
5.6.310.0040.00816.08
5.6.300.0060.01216.25
5.6.290.0090.00416.24
5.6.280.0070.03918.71
5.6.270.0100.01016.30
5.6.260.0120.00616.11
5.6.250.0090.00616.04
5.6.240.0030.01016.25
5.6.230.0100.00316.11
5.6.220.0070.01416.38
5.6.210.0080.02218.26
5.6.200.0050.03017.13
5.6.190.0000.04918.45
5.6.180.0110.02318.34
5.6.170.0120.04018.21
5.6.160.0070.05118.38
5.6.150.0100.04317.18
5.6.140.0050.04417.27
5.6.130.0070.03317.29
5.6.120.0030.03018.56
5.6.110.0110.03618.69
5.6.100.0070.04718.63
5.6.90.0080.04318.64
5.6.80.0020.03018.11
5.6.70.0030.01016.08
5.6.60.0070.00715.85
5.6.50.0030.01316.19
5.6.40.0000.01216.03
5.6.30.0120.00316.18
5.6.20.0110.00316.26
5.6.10.0030.00715.89
5.6.00.0040.01216.12
5.5.380.0070.00716.27
5.5.370.0080.00416.08
5.5.360.0060.01216.05
5.5.350.0150.04218.33
5.5.340.0100.02817.06
5.5.330.0070.04518.16
5.5.320.0200.02418.08
5.5.310.0180.03218.16
5.5.300.0070.04017.03
5.5.290.0050.02916.99
5.5.280.0050.02518.40
5.5.270.0080.04418.29
5.5.260.0140.03718.38
5.5.250.0070.03818.33
5.5.240.0090.02518.06
5.5.230.0030.00916.00
5.5.220.0080.00815.96
5.5.210.0000.01315.84
5.5.200.0040.01116.11
5.5.190.0060.00915.92
5.5.180.0040.01116.00
5.5.170.0110.00416.01
5.5.160.0000.01316.04
5.5.150.0090.00616.18
5.5.140.0070.00416.03
5.5.130.0150.00016.03
5.5.120.0080.00816.00
5.5.110.0070.00716.11
5.5.100.0090.00615.76
5.5.90.0090.00616.14
5.5.80.0000.01616.05
5.5.70.0060.00315.87
5.5.60.0060.00315.95
5.5.50.0070.01015.93
5.5.40.0100.00616.16
5.5.30.0120.00615.84
5.5.20.0110.00316.15
5.5.10.0070.00715.85
5.5.00.0070.00716.05
5.4.450.0180.03216.22
5.4.440.0430.03416.23
5.4.430.0110.02715.97
5.4.420.0100.03615.96
5.4.410.0020.03716.27
5.4.400.0080.02815.96
5.4.390.0120.03815.98
5.4.380.0060.03215.63
5.4.370.0130.03015.92
5.4.360.0090.03615.93
5.4.350.0050.02413.27
5.4.340.0080.01813.29
5.4.330.0050.00312.74
5.4.320.0060.02113.51
5.4.310.0030.02613.47
5.4.300.0090.02513.60
5.4.290.0020.02813.63
5.4.280.0030.02213.58
5.4.270.0000.02513.47
5.4.260.0080.02013.58
5.4.250.0080.02813.54
5.4.240.0090.02713.51
5.4.230.0070.02013.60
5.4.220.0070.01813.43
5.4.210.0060.02113.42
5.4.200.0070.02213.49
5.4.190.0090.02213.53
5.4.180.0070.02013.45
5.4.170.0060.02113.47
5.4.160.0110.02013.62
5.4.150.0090.01913.50
5.4.140.0020.02613.33
5.4.130.0060.02013.28
5.4.120.0100.02013.29
5.4.110.0070.02213.29
5.4.100.0020.02513.29
5.4.90.0050.02313.30
5.4.80.0060.02113.37
5.4.70.0080.01513.23
5.4.60.0050.02413.39
5.4.50.0050.02013.34
5.4.40.0020.02713.51
5.4.30.0050.02313.29
5.4.20.0070.02013.39
5.4.10.0120.02213.27
5.4.00.0100.01813.14
5.3.290.0100.03714.72
5.3.280.0000.04714.54
5.3.270.0100.03714.78
5.3.260.0030.04314.72
5.3.250.0030.04314.65
5.3.240.0130.03314.57
5.3.230.0030.04314.60
5.3.220.0070.04014.57
5.3.210.0070.04314.64
5.3.200.0100.04014.54
5.3.190.0070.04314.64
5.3.180.0030.04014.62
5.3.170.0100.03314.63
5.3.160.0130.03714.76
5.3.150.0070.04014.62
5.3.140.0070.03714.55
5.3.130.0100.03714.60
5.3.120.0030.04314.50
5.3.110.0070.03714.72
5.3.100.0100.04314.00
5.3.90.0100.04014.01
5.3.80.0130.03014.15
5.3.70.0100.04314.06
5.3.60.0070.03714.14
5.3.50.0030.04014.00
5.3.40.0070.03714.08
5.3.30.0070.03713.80
5.3.20.0070.03713.70
5.3.10.0030.04713.64
5.3.00.0100.04013.63
5.2.170.0000.04011.22
5.2.160.0000.03311.20
5.2.150.0130.03011.23
5.2.140.0030.03311.20
5.2.130.0100.03011.09
5.2.120.0030.03011.08
5.2.110.0070.03011.13
5.2.100.0030.03311.09
5.2.90.0070.03011.27
5.2.80.0070.03011.08
5.2.70.0070.02711.23
5.2.60.0000.03711.07
5.2.50.0070.03311.10
5.2.40.0030.03010.96
5.2.30.0100.02711.10
5.2.20.0030.03010.89
5.2.10.0070.02711.05
5.2.00.0030.03010.78
5.1.60.0100.01710.04
5.1.50.0000.03010.05
5.1.40.0070.0209.95
5.1.30.0130.02010.39
5.1.20.0000.03010.32
5.1.10.0070.02310.05
5.1.00.0000.03010.27
5.0.50.0000.0238.63
5.0.40.0070.0178.48
5.0.30.0030.0308.22
5.0.20.0070.0178.40
5.0.10.0030.0208.32
5.0.00.0070.0308.16
4.4.90.0100.0175.88
4.4.80.0000.0275.97
4.4.70.0030.0175.95
4.4.60.0030.0175.95
4.4.50.0000.0176.02
4.4.40.0070.0235.83
4.4.30.0030.0175.83
4.4.20.0070.0176.02
4.4.10.0070.0205.94
4.4.00.0000.0306.00
4.3.110.0030.0235.82
4.3.100.0000.0175.79
4.3.90.0030.0135.87
4.3.80.0030.0235.86
4.3.70.0030.0205.75
4.3.60.0030.0135.74
4.3.50.0070.0135.79
4.3.40.0100.0205.75
4.3.30.0030.0174.55
4.3.20.0000.0174.48
4.3.10.0030.0134.48
4.3.00.0130.0237.09

preferences:
37.73 ms | 401 KiB | 5 Q