3v4l.org

run code in 300+ PHP versions simultaneously
<?php function incrementWithSwitch($date, $invert) { $timezone = $date->getTimezone(); $date = $date->setTimezone(new DateTimeZone('UTC')); $date = $date->modify(($invert ? '-' : '+') . '1 hour'); $date = $date->setTimezone($timezone); $date = $date->setTime((int)$date->format('H'), 0); return $date; } function incrementWithoutSwitch($date, $invert) { $date = $date->modify(($invert ? '-' : '+') . '1 hour'); return $date; } $tz = new \DateTimeZone("Europe/London"); $dtWith = \DateTimeImmutable::createFromFormat("!Y-m-d H:i:s", "2021-03-28 04:00:00"); $dtWithout = $dtWith; $invert = true; for ($i = 0; $i < 3; $i++) { print "\nRound {$i}:"; $dtWith = incrementWithSwitch($dtWith, $invert); $dtWithout = incrementWithoutSwitch($dtWithout, $invert); print "With switch: ". $dtWith->format(\DateTime::RFC3339); print " :: Without switch: ". $dtWithout->format(\DateTime::RFC3339); } print "\n---\n"; $dtWith = \DateTimeImmutable::createFromFormat("!Y-m-d H:i:s", "2021-03-28 00:00:00"); $dtWithout = $dtWith; $invert = false; for ($i = 0; $i < 3; $i++) { print "\nRound {$i}:"; $dtWith = incrementWithSwitch($dtWith, $invert); $dtWithout = incrementWithoutSwitch($dtWithout, $invert); print "With switch: ". $dtWith->format(\DateTime::RFC3339); print " :: Without switch: ". $dtWithout->format(\DateTime::RFC3339); }

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.4.120.0050.00422.27
8.4.110.0100.01020.47
8.4.100.0120.00817.83
8.4.90.0110.00917.95
8.4.80.0100.01117.95
8.4.70.0170.00617.82
8.4.60.0130.00917.86
8.4.50.0120.00718.82
8.4.40.0250.00818.72
8.4.30.0170.01119.02
8.4.20.0200.00918.24
8.4.10.0240.00417.76
8.3.250.0130.00618.86
8.3.240.0060.00216.54
8.3.230.0130.00616.70
8.3.220.0060.00418.35
8.3.210.0090.01016.66
8.3.200.0100.01116.54
8.3.190.0110.00716.54
8.3.180.0120.00716.65
8.3.170.0220.01017.89
8.3.160.0210.00718.55
8.3.150.0270.00516.76
8.3.140.0210.01017.68
8.3.130.0180.01017.40
8.3.120.0150.01117.85
8.3.110.0200.00518.75
8.3.100.0240.00920.20
8.3.90.0210.00721.70
8.3.80.0220.00416.46
8.3.70.0250.00516.68
8.3.60.0240.01016.72
8.3.50.0250.00716.42
8.3.40.0200.00918.31
8.3.30.0180.00918.22
8.3.20.0190.00520.81
8.3.10.0190.00321.17
8.3.00.0110.00721.91
8.2.290.0050.01419.32
8.2.280.0120.00716.61
8.2.270.0200.00817.88
8.2.260.0130.01116.73
8.2.250.0200.00516.54
8.2.240.0150.00817.20
8.2.230.0130.00719.58
8.2.220.0140.01227.18
8.2.210.0180.00621.62
8.2.200.0210.00316.69
8.2.190.0250.00916.71
8.2.180.0180.01021.35
8.2.170.0210.00918.37
8.2.160.0240.00520.36
8.2.150.0210.00321.63
8.2.140.0150.01021.21
8.2.130.0200.00521.96
8.2.120.0150.00921.92
8.2.110.0170.00520.11
8.2.100.0130.00218.01
8.2.90.0150.00918.62
8.2.80.0200.00418.07
8.2.70.0160.00717.79
8.2.60.0220.00218.00
8.2.50.0160.00917.89
8.2.40.0170.00618.81
8.2.30.0140.00717.97
8.2.20.0100.01017.83
8.2.10.0120.01218.52
8.2.00.0150.01018.66
8.1.330.0130.00616.52
8.1.320.0090.01018.19
8.1.310.0160.00917.32
8.1.300.0260.00317.24
8.1.290.0150.01023.38
8.1.280.0200.01121.08
8.1.270.0150.01221.02
8.1.260.0180.00421.97
8.1.250.0140.00822.83
8.1.240.0130.00720.78
8.1.230.0180.00517.71
8.1.220.0120.01017.68
8.1.210.0160.00518.11
8.1.200.0150.00817.50
8.1.190.0190.00417.42
8.1.180.0130.00817.78
8.1.170.0210.00318.05
8.1.160.0210.00718.35
8.1.150.0120.00718.16
8.1.140.0130.00818.22
8.1.130.0140.00718.81
8.1.120.0110.01117.68
8.1.110.0120.00817.66
8.1.100.0140.00717.66
8.1.90.0180.00317.52
8.1.80.0120.01017.61
8.1.70.0160.00517.61
8.1.60.0110.00917.72
8.1.50.0130.00917.61
8.1.40.0110.01117.56
8.1.30.0070.00617.80
8.1.20.0170.00317.78
8.1.10.0150.00617.60
8.1.00.0180.00517.51
8.0.300.0170.00517.75
8.0.290.0150.01016.91
8.0.280.0160.00617.76
8.0.270.0170.00617.53
8.0.260.0170.00517.77
8.0.250.0120.00517.09
8.0.240.0170.00217.12
8.0.230.0150.00917.06
8.0.220.0150.00717.10
8.0.210.0110.01117.06
8.0.200.0160.00517.13
8.0.190.0160.00417.08
8.0.180.0170.00816.87
8.0.170.0190.00416.93
8.0.160.0190.00516.83
8.0.150.0130.00917.07
8.0.140.0120.00916.95
8.0.130.0100.01015.08
8.0.120.0170.00516.99
8.0.110.0160.00316.98
8.0.100.0080.01217.00
8.0.90.0150.00816.79
8.0.80.0150.00717.09
8.0.70.0130.00916.89
8.0.60.0160.00617.06
8.0.50.0140.00816.84
8.0.30.0200.01116.99
8.0.20.0240.00717.16
8.0.10.0190.00617.27
8.0.00.0230.00217.09
7.4.330.0160.00316.10
7.4.320.0160.00316.46
7.4.300.0170.00216.65
7.4.290.0190.00316.54
7.4.280.0180.00216.66
7.4.270.0130.00616.70
7.4.260.0150.00314.84
7.4.250.0110.00916.63
7.4.240.0130.00616.66
7.4.230.0140.00616.61
7.4.220.0080.00816.50
7.4.210.0160.00416.66
7.4.200.0190.00516.64
7.4.190.0290.00716.68
7.4.180.0270.00516.52
7.4.160.0160.00916.61
7.4.150.0150.00916.66
7.4.140.0130.01016.48
7.4.130.0200.00316.62
7.4.120.0160.00816.61
7.4.110.0170.00616.59
7.4.100.0260.00016.71
7.4.90.0220.00416.66
7.4.80.0120.01416.69
7.4.70.0160.00916.65
7.4.60.0200.00416.65
7.4.50.0170.00716.43
7.4.40.0140.01016.46
7.4.30.0150.00816.52
7.4.20.0150.01016.53
7.4.10.0240.00516.54
7.4.00.0140.01016.62
7.3.330.0090.00416.42
7.3.320.0090.01014.90
7.3.310.0100.00516.50
7.3.300.0050.00516.47
7.3.290.0100.00616.57
7.3.280.0130.00416.55
7.3.270.0190.00516.58
7.3.260.0150.00816.68
7.3.250.0180.00716.46
7.3.240.0160.00616.51
7.3.230.0120.00816.39
7.3.220.0210.00516.49
7.3.210.0220.00316.45
7.3.200.0210.00616.31
7.3.190.0200.00916.47
7.3.180.0190.00616.55
7.3.170.0210.00616.52
7.3.160.0170.00616.44
7.3.150.0180.00516.55
7.3.140.0220.00616.50
7.3.130.0230.00316.53
7.3.120.0120.00916.46
7.3.110.0130.01016.49
7.3.100.0180.00516.36
7.3.90.0230.00216.76
7.3.80.0150.00816.55
7.3.70.0200.00516.54
7.3.60.0170.00916.56
7.3.50.0170.00816.45
7.3.40.0230.00616.54
7.3.30.0140.01116.60
7.3.20.0190.00817.49
7.3.10.0180.00917.55
7.3.00.0210.00617.43

preferences:
28.33 ms | 403 KiB | 5 Q