3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Sleep { protected ?int $pending = null; public function __construct(int $duration) { $this->pending = $duration; } public static function for(int $duration): static { return new static($duration); } public function one(): static { $this->pending = 100; return $this; } public function two(): static { $this->pending = 200; return $this; } public function __destruct() { if ($this->pending > 0) { echo 'Sleeping for ' . $this->pending . ' μseconds' . PHP_EOL; echo PHP_EOL; usleep($this->pending); } } } function check(bool $a) { $sleep = (new Sleep(2))->one(); if ($a) { $sleep->two(); } // author expecting two seconds or one minute to be slept before calling next line: 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.0100.01124.35
8.4.110.0160.00518.02
8.4.100.0130.00719.08
8.4.90.0110.01020.44
8.4.80.0050.00420.52
8.4.70.0130.00618.29
8.4.60.0080.01418.80
8.4.50.0090.00918.72
8.4.40.0180.00417.85
8.4.30.0080.00018.89
8.4.20.0060.00618.03
8.4.10.0030.00619.48
8.3.250.0050.00818.77
8.3.240.0130.00717.08
8.3.230.0110.00916.84
8.3.220.0120.00619.12
8.3.210.0120.00716.71
8.3.200.0030.00616.79
8.3.190.0080.01017.33
8.3.180.0070.00617.26
8.3.170.0150.00320.86
8.3.160.0090.00916.60
8.3.150.0090.00917.59
8.3.140.0160.00016.71
8.3.130.0040.00417.11
8.3.120.0090.00018.67
8.3.110.0070.00720.94
8.3.100.0030.00624.06
8.3.90.0000.00826.77
8.3.80.0060.00318.55
8.3.70.0130.00318.43
8.3.60.0120.00616.75
8.3.50.0090.00616.86
8.3.40.0120.00320.52
8.3.30.0050.01020.35
8.3.20.0080.00024.18
8.3.10.0000.00824.66
8.3.00.0060.00328.09
8.2.290.0100.00920.43
8.2.280.0120.00818.31
8.2.270.0120.00617.14
8.2.260.0060.00316.75
8.2.250.0040.00418.66
8.2.240.0040.00419.11
8.2.230.0000.00922.58
8.2.220.0070.00337.54
8.2.210.0100.01026.77
8.2.200.0000.01016.63
8.2.190.0160.00316.63
8.2.180.0130.01016.50
8.2.170.0180.00319.01
8.2.160.0090.00622.96
8.2.150.0050.00325.66
8.2.140.0080.00024.66
8.2.130.0030.00528.09
8.2.120.0080.00028.09
8.2.60.0100.01028.09
8.1.330.0130.00721.91
8.1.320.0100.01218.45
8.1.310.0000.01116.29
8.1.300.0100.00518.09
8.1.290.0060.00330.84
8.1.280.0180.00325.92
8.1.270.0090.00622.13
8.1.260.0040.00428.09
8.1.250.0040.00428.09

preferences:
57.78 ms | 403 KiB | 5 Q