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-15', 'end' => '2013-12-31'), array('start' => '2014-01-01', 'end' => '2014-01-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.0070.00716.38
8.3.50.0120.00522.86
8.3.40.0140.00418.77
8.3.30.0080.00619.40
8.3.20.0000.00820.32
8.3.10.0040.00421.77
8.3.00.0040.00419.80
8.2.180.0070.01116.50
8.2.170.0060.01022.96
8.2.160.0100.01021.06
8.2.150.0040.00424.18
8.2.140.0050.00524.66
8.2.130.0080.00026.16
8.2.120.0050.00321.14
8.2.110.0090.00322.21
8.2.100.0110.00019.21
8.2.90.0050.00319.10
8.2.80.0030.00519.26
8.2.70.0050.00317.75
8.2.60.0030.00618.18
8.2.50.0030.00618.07
8.2.40.0040.00418.22
8.2.30.0030.00518.09
8.2.20.0080.00018.02
8.2.10.0050.00318.18
8.2.00.0030.00617.87
8.1.280.0090.00625.92
8.1.270.0070.00322.16
8.1.260.0110.00726.35
8.1.250.0000.00728.09
8.1.240.0060.00323.84
8.1.230.0110.00019.14
8.1.220.0030.00517.79
8.1.210.0050.00318.77
8.1.200.0060.00317.35
8.1.190.0000.00817.66
8.1.180.0070.00020.16
8.1.170.0060.00318.54
8.1.160.0050.00322.16
8.1.150.0040.00418.88
8.1.140.0040.00417.62
8.1.130.0080.00018.03
8.1.120.0040.00417.72
8.1.110.0000.00817.69
8.1.100.0070.00017.68
8.1.90.0080.00017.71
8.1.80.0040.00417.64
8.1.70.0000.00717.63
8.1.60.0060.00317.66
8.1.50.0050.00317.73
8.1.40.0080.00317.58
8.1.30.0050.00317.83
8.1.20.0040.00417.84
8.1.10.0000.00817.75
8.1.00.0000.00717.59
8.0.300.0000.00718.77
8.0.290.0020.00517.30
8.0.280.0070.00018.52
8.0.270.0080.00017.33
8.0.260.0000.00817.19
8.0.250.0030.00317.07
8.0.240.0030.00317.04
8.0.230.0000.00717.21
8.0.220.0000.00717.13
8.0.210.0030.00616.99
8.0.200.0040.00417.14
8.0.190.0000.00817.19
8.0.180.0000.00717.14
8.0.170.0040.00417.16
8.0.160.0040.00417.09
8.0.150.0030.00617.01
8.0.140.0000.00717.04
8.0.130.0000.00613.44
8.0.120.0000.00816.97
8.0.110.0040.00417.11
8.0.100.0000.00717.05
8.0.90.0000.00717.11
8.0.80.0060.01017.17
8.0.70.0000.00716.95
8.0.60.0040.00417.01
8.0.50.0040.00417.11
8.0.30.0100.00917.03
8.0.20.0120.00617.40
8.0.10.0040.00317.09
8.0.00.0070.01116.81
7.4.330.0000.00615.14
7.4.320.0030.00316.57
7.4.300.0030.00316.74
7.4.290.0090.00016.73
7.4.280.0030.00316.81
7.4.270.0000.00716.64
7.4.260.0000.00716.69
7.4.250.0000.00716.72
7.4.240.0060.00116.69
7.4.230.0000.00716.75
7.4.220.0180.00916.77
7.4.210.0130.00416.79
7.4.200.0030.00316.46
7.4.160.0090.00616.77
7.4.150.0070.01117.40
7.4.140.0120.00917.86
7.4.130.0080.01016.63
7.4.120.0120.00616.62
7.4.110.0180.00016.59
7.4.100.0160.00016.62
7.4.90.0110.00716.56
7.4.80.0060.01219.39
7.4.70.0030.01316.65
7.4.60.0100.00716.62
7.4.50.0030.00516.55
7.4.40.0080.00816.71
7.4.30.0070.01516.70
7.4.10.0090.00916.70
7.4.00.0040.01415.83
7.3.330.0000.00513.37
7.3.320.0000.00613.43
7.3.310.0050.00216.52
7.3.300.0030.00316.48
7.3.290.0100.00816.51
7.3.280.0050.01116.44
7.3.270.0100.00717.40
7.3.260.0070.01116.59
7.3.250.0110.00716.75
7.3.240.0150.00416.64
7.3.230.0100.00716.60
7.3.210.0130.00416.52
7.3.200.0030.01519.39
7.3.190.0100.01016.58
7.3.180.0070.01016.74
7.3.170.0160.00016.83
7.3.160.0030.01316.54
7.3.130.0080.01216.75
7.3.120.0090.00815.69
7.3.110.0070.00915.95
7.3.100.0050.01115.87
7.3.90.0050.00415.85
7.3.80.0050.00815.57
7.3.70.0070.00515.72
7.3.60.0060.00515.75
7.3.50.0060.01015.56
7.3.40.0050.00915.76
7.3.30.0020.00915.78
7.3.20.0080.00817.47
7.3.10.0070.01017.58
7.3.00.0080.00317.43
7.2.330.0150.00316.93
7.2.320.0070.01017.05
7.2.310.0100.01417.06
7.2.300.0030.01316.71
7.2.290.0100.00916.95
7.2.260.0120.00617.01
7.2.250.0060.01117.06
7.2.240.0090.00616.15
7.2.230.0070.01015.86
7.2.220.0100.00415.86
7.2.210.0050.00916.14
7.2.200.0030.01016.01
7.2.190.0080.00615.96
7.2.180.0070.00616.07
7.2.170.0080.00616.07
7.2.160.0070.00516.13
7.2.150.0040.00917.72
7.2.140.0050.00717.90
7.2.130.0080.00317.98
7.2.120.0060.00817.89
7.2.110.0050.00917.74
7.2.100.0000.01617.87
7.2.90.0090.00617.93
7.2.80.0080.00617.79
7.2.70.0080.00617.92
7.2.60.0050.00717.89
7.2.50.0070.00517.75
7.2.40.0070.00917.84
7.2.30.0070.00617.79
7.2.20.0020.00817.93
7.2.10.0100.00617.73
7.2.00.0060.00818.37
7.1.330.0050.01116.83
7.1.320.0060.01016.73
7.1.310.0060.00916.75
7.1.300.0050.00916.78
7.1.290.0060.00816.64
7.1.280.0060.00616.77
7.1.270.0050.00816.76
7.1.260.0050.00716.74
7.1.250.0010.00916.70
7.1.240.0100.00317.39
7.1.230.0120.00317.39
7.1.220.0120.00417.59
7.1.210.0090.00617.45
7.1.200.0110.00717.45
7.1.190.0030.01217.49
7.1.180.0070.00717.28
7.1.170.0030.01017.39
7.1.160.0000.01417.63
7.1.150.0000.01517.61
7.1.140.0030.00717.46
7.1.130.0090.00617.52
7.1.120.0000.01317.31
7.1.110.0120.00617.36
7.1.100.0060.00517.86
7.1.90.0100.00717.54
7.1.80.0070.00317.41
7.1.70.0050.00517.39
7.1.60.0080.01018.45
7.1.50.0090.01017.19
7.1.40.0100.00317.71
7.1.30.0000.01617.46
7.1.20.0040.01117.29
7.1.10.0130.00317.57
7.1.00.0070.04019.93
7.0.330.0060.00317.06
7.0.320.0060.00317.14
7.0.310.0040.01117.23
7.0.300.0000.01417.14
7.0.290.0030.00916.97
7.0.280.0080.00817.09
7.0.270.0060.00917.17
7.0.260.0070.01116.89
7.0.250.0000.01017.14
7.0.240.0150.00017.29
7.0.230.0110.00417.07
7.0.220.0120.00017.04
7.0.210.0030.00617.15
7.0.200.0020.01017.03
7.0.190.0040.00717.18
7.0.180.0000.01117.20
7.0.170.0070.01117.48
7.0.160.0060.01317.30
7.0.150.0060.01217.29
7.0.140.0070.03719.67
7.0.130.0070.00717.37
7.0.120.0060.00917.39
7.0.110.0030.00917.05
7.0.100.0040.00917.14
7.0.90.0030.01017.23
7.0.80.0120.00316.97
7.0.70.0110.00017.23
7.0.60.0180.03819.46
7.0.50.0100.02017.50
7.0.40.0100.04717.54
7.0.30.0130.03517.70
7.0.20.0150.03017.65
7.0.10.0070.04717.64
7.0.00.0090.02017.77
5.6.400.0070.00716.26
5.6.390.0000.01316.36
5.6.380.0000.01515.95
5.6.370.0030.01016.31
5.6.360.0040.00715.96
5.6.350.0000.01615.75
5.6.340.0040.01216.30
5.6.330.0030.01016.30
5.6.320.0100.00016.24
5.6.310.0070.01116.28
5.6.300.0130.00016.40
5.6.290.0060.00616.08
5.6.280.0050.03818.59
5.6.270.0070.00716.16
5.6.260.0040.01416.24
5.6.250.0110.00416.11
5.6.240.0030.00616.24
5.6.230.0060.00916.24
5.6.220.0030.01615.97
5.6.210.0130.04318.62
5.6.200.0080.04117.12
5.6.190.0070.02518.37
5.6.180.0210.02018.35
5.6.170.0210.04218.30
5.6.160.0030.03218.43
5.6.150.0080.04017.31
5.6.140.0080.04317.15
5.6.130.0050.05017.21
5.6.120.0060.04118.60
5.6.110.0080.04318.77
5.6.100.0030.03518.52
5.6.90.0090.04018.54
5.6.80.0080.02018.29
5.6.70.0110.00415.98
5.6.60.0040.01116.12
5.6.50.0120.00316.10
5.6.40.0030.00915.99
5.6.30.0060.00916.14
5.6.20.0070.01115.84
5.6.10.0000.01316.21
5.6.00.0000.01315.98
5.5.380.0030.01016.02
5.5.370.0070.00715.97
5.5.360.0000.01816.03
5.5.350.0130.04218.30
5.5.340.0090.02117.09
5.5.330.0050.02618.09
5.5.320.0140.02218.34
5.5.310.0070.02718.13
5.5.300.0050.03716.93
5.5.290.0100.04317.00
5.5.280.0120.04018.54
5.5.270.0050.03218.50
5.5.260.0070.02318.46
5.5.250.0080.04518.39
5.5.240.0080.02618.04
5.5.230.0110.00416.07
5.5.220.0070.00715.99
5.5.210.0090.00915.81
5.5.200.0060.00316.01
5.5.190.0060.01215.87
5.5.180.0000.01016.07
5.5.170.0060.00616.01
5.5.160.0030.01015.97
5.5.150.0040.01116.13
5.5.140.0040.01115.96
5.5.130.0040.00815.96
5.5.120.0090.00616.02
5.5.110.0070.00716.11
5.5.100.0030.00816.07
5.5.90.0040.01116.15
5.5.80.0030.00616.07
5.5.70.0090.00616.04
5.5.60.0150.00415.93
5.5.50.0030.00616.00
5.5.40.0080.00316.00
5.5.30.0070.00716.12
5.5.20.0030.01316.22
5.5.10.0060.00716.11
5.5.00.0100.00715.93
5.4.450.0220.03716.13
5.4.440.0200.03816.35
5.4.430.0100.02816.28
5.4.420.0180.02816.17
5.4.410.0150.04316.24
5.4.400.0230.03616.07
5.4.390.0280.02016.14
5.4.380.0130.03516.01
5.4.370.0150.02715.98
5.4.360.0120.03016.13
5.4.350.0170.02716.01
5.4.340.0200.03715.92
5.4.330.0040.00713.07
5.4.320.0200.03615.99
5.4.310.0180.03815.95
5.4.300.0200.03516.07
5.4.290.0130.02716.01
5.4.280.0120.02715.93
5.4.270.0170.03016.05
5.4.260.0200.02515.85
5.4.250.0120.03916.10
5.4.240.0150.02515.97
5.4.230.0130.02516.11
5.4.220.0200.03216.05
5.4.210.0170.03315.80
5.4.200.0100.03715.98
5.4.190.0150.04015.99
5.4.180.0150.03416.05
5.4.170.0200.02716.09
5.4.160.0200.03316.02
5.4.150.0150.02715.87
5.4.140.0180.03014.71
5.4.130.0190.03014.72
5.4.120.0140.02514.69
5.4.110.0190.03514.79
5.4.100.0140.02014.59
5.4.90.0130.02014.67
5.4.80.0160.02214.78
5.4.70.0130.02214.81
5.4.60.0130.02214.67
5.4.50.0170.02614.73
5.4.40.0120.04314.53
5.4.30.0240.02814.58
5.4.20.0170.03314.75
5.4.10.0150.02014.58
5.4.00.0130.03314.46
5.3.290.0330.07314.84
5.3.280.0270.05314.66
5.3.270.0330.03314.77
5.3.260.0300.05014.66
5.3.250.0370.04314.68
5.3.240.0430.05714.63
5.3.230.0330.04014.53
5.3.220.0330.05314.63
5.3.210.0230.04014.58
5.3.200.0270.04314.58
5.3.190.0200.04714.63
5.3.180.0300.06714.47
5.3.170.0270.04014.63
5.3.160.0200.05014.59
5.3.150.0230.04014.61
5.3.140.0230.07314.46
5.3.130.0300.06314.57
5.3.120.0430.04714.56
5.3.110.0330.06014.57
5.3.100.0230.05014.06
5.3.90.0230.03314.04
5.3.80.0270.06713.98
5.3.70.0200.07014.09
5.3.60.0300.05714.02
5.3.50.0370.05013.96
5.3.40.0200.03713.96
5.3.30.0270.06714.08
5.3.20.0200.07313.75
5.3.10.0130.04013.59
5.3.00.0270.06313.66
5.2.170.0230.06011.18
5.2.160.0170.05711.16
5.2.150.0200.06011.18
5.2.140.0270.02011.21
5.2.130.0270.02311.16
5.2.120.0200.02711.13
5.2.110.0230.05011.15
5.2.100.0200.05711.06
5.2.90.0270.05311.00
5.2.80.0200.05311.25
5.2.70.0170.03311.14
5.2.60.0270.04711.03
5.2.50.0300.03711.17
5.2.40.0200.05310.96
5.2.30.0230.04010.91
5.2.20.0230.05710.93
5.2.10.0130.06710.82
5.2.00.0300.03310.88
5.1.60.0170.04710.01
5.1.50.0200.06010.08
5.1.40.0270.02710.06
5.1.30.0170.02710.24
5.1.20.0230.02710.29
5.1.10.0230.03710.06
5.1.00.0200.05310.11
5.0.50.0070.0339.25
5.0.40.0100.0479.25
5.0.30.0130.0339.25
5.0.20.0100.0239.25
5.0.10.0130.0339.25
5.0.00.0100.0639.25
4.4.90.0100.0379.25
4.4.80.0100.0279.25
4.4.70.0070.0239.25
4.4.60.0100.0239.25
4.4.50.0130.0179.25
4.4.40.0170.0409.25
4.4.30.0100.0309.25
4.4.20.0100.0279.25
4.4.10.0130.0309.25
4.4.00.0170.0379.25
4.3.110.0100.0379.25
4.3.100.0130.0309.25
4.3.90.0170.0109.25
4.3.80.0200.0439.25
4.3.70.0130.0179.25
4.3.60.0130.0179.25
4.3.50.0130.0339.25
4.3.40.0130.0439.25
4.3.30.0030.0379.25
4.3.20.0070.0179.25
4.3.10.0100.0279.25
4.3.00.0030.0379.25

preferences:
54.38 ms | 401 KiB | 5 Q