3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace Repro; class CycleValue { private ?\stdClass $cycleRef; public function __construct() { // make self cyclically referenced $this->cycleRef = new \stdClass(); $this->cycleRef->x = $this; } public function __destruct() { echo "d\n"; $this->cycleRef->x = null; $this->cycleRef = null; } } class CycleWithDestructorForGcMonitoring { private \Closure $destructorFx; private \stdClass $cycleRef; public function __construct(\Closure $destructorFx) { $this->destructorFx = $destructorFx; $this->cycleRef = new \stdClass(); $this->cycleRef->x = $this; } public function __destruct() { ($this->destructorFx)(); } } $ref = \WeakReference::create(new CycleValue()); $isSecondGcRerun = false; // https://github.com/php/php-src/commit/b58d74547f $createMonitorGcFx = static function () use ($ref): void { $destructorFx = static function () use ($ref): void { echo "gc\n"; var_dump($ref->get() !== null); var_dump($ref->get() !== null); }; new CycleWithDestructorForGcMonitoring($destructorFx); }; $createMonitorGcFx(); gc_collect_cycles(); /**/if (PHP_VERSION_ID < 80100) { gc_collect_cycles(); } echo "done\n";

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.5.30.0100.01021.34
8.5.20.0090.00820.17
8.5.10.0110.00716.67
8.5.00.0120.00920.18
8.4.170.0090.01223.86
8.4.160.0120.00923.83
8.4.150.0020.00014.05
8.4.140.0180.00517.63
8.4.130.0110.00917.96
8.4.120.0130.00723.84
8.4.110.0110.00622.43
8.4.100.0160.00518.64
8.4.90.0100.01018.75
8.4.80.0120.00718.71
8.4.70.0060.00318.00
8.4.60.0100.00718.89
8.4.50.0060.00318.76
8.4.40.0030.00619.70
8.4.30.0130.00618.68
8.4.20.0140.00719.89
8.4.10.0000.00819.27
8.3.300.0090.01220.94
8.3.290.0100.01020.82
8.3.280.0100.01018.49
8.3.270.0110.00716.58
8.3.260.0100.00916.80
8.3.250.0120.00719.04
8.3.240.0120.00517.40
8.3.230.0070.01316.64
8.3.220.0090.00618.96
8.3.210.0070.00116.54
8.3.200.0050.00316.48
8.3.190.0120.00617.39
8.3.180.0110.00817.00
8.3.170.0070.00719.05
8.3.160.0190.00017.13
8.3.150.0070.01117.45
8.3.140.0080.01116.76
8.3.130.0040.00818.27
8.3.120.0040.00420.63
8.3.110.0150.00020.94
8.3.100.0050.00524.06
8.3.90.0150.00426.77
8.3.80.0040.00417.97
8.3.70.0130.00316.50
8.3.60.0110.00418.54
8.3.50.0120.00318.38
8.3.40.0070.00723.64
8.3.30.0130.00922.96
8.3.20.0130.00622.96
8.3.10.0110.00722.96
8.3.00.0130.00622.96
8.2.300.0170.00618.88
8.2.290.0110.00720.54
8.2.280.0030.00518.71
8.2.270.0040.00418.91
8.2.260.0150.00418.17
8.2.250.0120.00317.07
8.2.240.0030.00717.32
8.2.230.0000.01122.58
8.2.220.0060.00337.54
8.2.210.0040.00426.77
8.2.200.0040.00716.38
8.2.190.0150.00016.58
8.2.180.0050.00916.47
8.2.170.0140.00022.96
8.2.160.0190.00022.96
8.2.150.0140.00722.96
8.2.140.0070.01322.96
8.2.130.0130.00722.96
8.2.120.0150.00422.96
8.2.110.0120.00622.96
8.2.100.0110.00722.96
8.2.90.0150.00322.96
8.2.80.0140.00722.96
8.2.70.0090.01222.96
8.2.60.0080.00822.96
8.2.50.0110.00422.96
8.2.40.0150.00622.96
8.2.30.0040.01122.96
8.2.20.0160.00622.96
8.2.10.0220.00022.96
8.2.00.0130.00322.96
8.1.340.0090.01221.55
8.1.330.0100.00821.74
8.1.320.0090.01016.06
8.1.310.0090.00918.63
8.1.300.0030.00616.19
8.1.290.0070.00330.84
8.1.280.0070.00725.92
8.1.270.0070.00722.96
8.1.260.0120.00322.96
8.1.250.0120.00322.96
8.1.240.0040.01222.96
8.1.230.0150.00022.96
8.1.220.0040.01222.96
8.1.210.0060.01022.96
8.1.200.0090.00922.96
8.1.190.0070.00722.96
8.1.180.0110.00722.96
8.1.170.0120.00322.96
8.1.160.0110.01122.96
8.1.150.0070.01122.96
8.1.140.0090.00922.96
8.1.130.0070.00722.96
8.1.120.0130.00622.96
8.1.110.0150.00022.96
8.1.100.0090.00922.96
8.1.90.0160.00322.96
8.1.80.0040.01122.96
8.1.70.0000.01422.96
8.1.60.0110.00422.96
8.1.50.0120.00622.96
8.1.40.0110.00722.96
8.1.30.0090.00922.96
8.1.20.0130.00622.96
8.1.10.0120.00422.96
8.1.00.0110.00422.96

preferences:
70.75 ms | 403 KiB | 5 Q