3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WeakMap2 { private array $weakRefs = []; private array $values = []; public function offsetSet($object, $value) : void { $id = spl_object_id($object); $this->weakRefs[$id] = \WeakReference::create($object); $this->values[$id] = $value; } } class WeakAnalysingMapRepro { public array $valueWithOwnerCountByIndex = []; private WeakMap2 $ownerDestructorHandlers; public function __construct() { $this->ownerDestructorHandlers = new WeakMap2(); $this->addKeyOwner(new \DateTime()); } protected function addKeyOwner(object $owner) { $handler = new class($this) { private \WeakReference $weakAnalysingMap; public function __construct(WeakAnalysingMapRepro $analysingMap) { $this->weakAnalysingMap = \WeakReference::create($analysingMap); } public function __destruct() { $analysingMap = $this->weakAnalysingMap->get(); var_dump(array_keys($analysingMap->valueWithOwnerCountByIndex)); \Closure::bind(static function () use ($analysingMap) { var_dump(array_keys($analysingMap->valueWithOwnerCountByIndex)); }, null, WeakAnalysingMapRepro::class)(); } public function addReference($index): void { $analysingMap = $this->weakAnalysingMap->get(); $analysingMap->valueWithOwnerCountByIndex[$index] = true; } }; $this->ownerDestructorHandlers->offsetSet($owner, $handler); $handler->addReference(10); } } $map = new WeakAnalysingMapRepro(); unset($map); echo 'DONE';

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.0130.00720.73
8.4.110.0160.00518.19
8.4.100.0110.00818.05
8.4.90.0140.00720.57
8.4.80.0110.00918.90
8.4.70.0040.00418.95
8.4.60.0100.01118.90
8.4.50.0100.01018.52
8.4.40.0120.00918.11
8.4.30.0030.01620.52
8.4.20.0130.00719.88
8.4.10.0090.00019.75
8.3.250.0080.00017.21
8.3.240.0060.00416.82
8.3.230.0060.00216.86
8.3.220.0100.00818.95
8.3.210.0100.00818.82
8.3.200.0070.00116.85
8.3.190.0100.00917.53
8.3.180.0100.01017.23
8.3.170.0120.00620.67
8.3.160.0110.00718.87
8.3.150.0100.01017.21
8.3.140.0110.00419.11
8.3.130.0040.00418.61
8.3.120.0060.00320.59
8.3.110.0000.00820.94
8.3.100.0070.00724.06
8.3.90.0040.00426.77
8.3.80.0030.00618.93
8.3.70.0090.01017.78
8.3.60.0270.00821.22
8.3.50.0120.00720.95
8.3.40.0200.01222.25
8.3.30.0240.00822.03
8.3.20.0240.00922.27
8.3.10.0260.00722.10
8.3.00.0290.00722.08
8.2.290.0120.00716.78
8.2.280.0100.00918.49
8.2.270.0120.00617.37
8.2.260.0090.00918.61
8.2.250.0000.00817.08
8.2.240.0030.00617.29
8.2.230.0060.00322.58
8.2.220.0060.00337.54
8.2.210.0110.00026.77
8.2.200.0000.01018.53
8.2.190.0160.00417.48
8.2.180.0170.00920.74
8.2.170.0260.00822.10
8.2.160.0230.01122.10
8.2.150.0300.00722.10
8.2.140.0260.01022.03
8.2.130.0230.01022.03
8.2.120.0270.00722.05
8.2.110.0230.01022.05
8.2.100.0260.00522.08
8.2.90.0220.01022.10
8.2.80.0240.00922.05
8.2.70.0220.01122.03
8.2.60.0250.00622.13
8.2.50.0260.00422.08
8.2.40.0220.00622.08
8.2.30.0220.00722.05
8.2.20.0250.00522.08
8.2.10.0240.01022.08
8.2.00.0250.00722.05
8.1.330.0080.01116.41
8.1.320.0120.00718.07
8.1.310.0040.00418.38
8.1.300.0040.00418.38
8.1.290.0030.00630.84
8.1.280.0300.00621.53
8.1.270.0230.01122.22
8.1.260.0280.00722.21
8.1.250.0280.00822.23
8.1.240.0220.00922.05
8.1.230.0200.01222.03
8.1.220.0190.01122.00
8.1.210.0250.00722.05
8.1.200.0250.00722.02
8.1.190.0260.00922.03
8.1.180.0260.00622.05
8.1.170.0200.00922.00
8.1.160.0250.00622.03
8.1.150.0210.00922.00
8.1.140.0230.00722.00
8.1.130.0240.00522.05
8.1.120.0250.00422.05
8.1.110.0260.00321.98
8.1.100.0220.00722.05
8.1.90.0230.00622.05
8.1.80.0230.00721.98
8.1.70.0220.00822.03
8.1.60.0240.00922.05
8.1.50.0230.00922.00
8.1.40.0210.01122.02
8.1.30.0280.00522.00
8.1.20.0260.00722.00
8.1.10.0250.00822.00
8.1.00.0230.00922.03

preferences:
28.36 ms | 403 KiB | 5 Q