3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Sleep { public static function for(Time $duration): void { usleep($duration->microseconds); } } readonly final class Time { public function __construct(public int $microseconds) { } public function add(self $time): self { return self::microseconds($this->microseconds + $time->microseconds); } public static function microseconds(int $duration): self { return new self($duration); } public static function milliseconds(int $duration): self { return new self($duration * 1000); } } function check(bool $a) { $sleep = Time::milliseconds(100); if ($a) { $sleep->add(Time::milliseconds(200)); } Sleep::for($sleep); echo 'CHECK:' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; } echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; check(false); echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; check(true); echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; // expected output: //OUTER_TIME: 2023-12-12T20:26:28+01:00 //Sleeping for 100 μseconds //CHECK:2023-12-12T20:26:28+01:00 // //OUTER_TIME: 2023-12-12T20:26:28+01:00 //Sleeping for 200 μseconds //CHECK:2023-12-12T20:26:28+01:00 // //OUTER_TIME: 2023-12-12T20:26:28+01:00

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.0060.00524.17
8.4.110.0140.00721.80
8.4.100.0070.00519.03
8.4.90.0130.00918.78
8.4.80.0110.01018.88
8.4.70.0090.00917.91
8.4.60.0140.00918.99
8.4.50.0170.00518.61
8.4.40.0040.00817.78
8.4.30.0040.00718.77
8.4.20.0110.00018.10
8.4.10.0000.01119.40
8.3.250.0140.00518.93
8.3.240.0080.00317.18
8.3.230.0150.00716.70
8.3.220.0070.01218.95
8.3.210.0080.01116.99
8.3.200.0070.00516.78
8.3.190.0140.00616.96
8.3.180.0110.00317.09
8.3.170.0030.01322.71
8.3.160.0040.01517.48
8.3.150.0130.01017.34
8.3.140.0060.01318.88
8.3.130.0060.00618.46
8.3.120.0080.00318.79
8.3.110.0070.00418.66
8.3.100.0030.00718.33
8.3.50.0120.00818.30
8.2.290.0110.00720.17
8.2.280.0130.00918.36
8.2.270.0160.00317.42
8.2.260.0040.00818.37
8.2.250.0030.00718.46
8.2.240.0140.00317.32
8.2.230.0080.00418.54
8.2.220.0130.00316.57
8.2.60.0150.00828.09
8.1.330.0130.00821.82
8.1.320.0120.00816.31
8.1.310.0120.00618.66
8.1.300.0100.00620.06

preferences:
37.64 ms | 403 KiB | 5 Q