3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasLoop($head) { $slow = $head; $fast = $head; while ($fast !== null && $fast->next !== null) { $slow = $slow->next; $fast = $fast->next->next; if ($slow === $fast) { return true; } } return false; } // example usage class Node { public $data; public $next; public function __construct($data) { $this->data = $data; $this->next = null; } } $a = new Node(1); $b = new Node(2); $c = new Node(3); $d = new Node(4); $a->next = $b; $b->next = $c; $c->next = $d; var_dump(hasLoop($a)); // false $d->next = $b; var_dump(hasLoop($a)); // true

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.00.0130.00820.07
8.4.150.0000.00114.05
8.4.140.0120.00917.54
8.4.130.0120.00818.82
8.4.120.0120.00819.08
8.4.110.0150.00518.95
8.4.100.0070.00218.03
8.4.90.0100.00920.61
8.4.80.0070.00619.13
8.4.70.0110.01019.07
8.4.60.0140.00620.64
8.4.50.0130.00720.43
8.4.40.0030.01717.45
8.4.30.0100.01020.46
8.4.20.0100.01019.69
8.4.10.0040.00422.29
8.3.280.0100.01018.41
8.3.270.0120.00816.76
8.3.260.0130.00616.63
8.3.250.0100.00518.63
8.3.240.0030.00516.52
8.3.230.0120.00716.58
8.3.220.0120.00519.17
8.3.210.0090.00918.47
8.3.200.0040.00516.64
8.3.190.0120.00717.16
8.3.180.0090.00616.43
8.3.170.0060.01217.12
8.3.160.0120.00920.36
8.3.150.0150.00418.98
8.3.140.0080.00017.22
8.3.130.0080.00016.52
8.3.120.0050.00518.72
8.3.110.0050.00520.94
8.3.100.0040.00424.06
8.3.90.0070.01126.77
8.3.80.0060.00316.50
8.3.70.0110.00716.75
8.3.60.0070.01420.00
8.3.50.0060.00916.59
8.3.40.0100.00720.16
8.3.30.0030.01020.06
8.3.20.0060.00324.18
8.3.10.0070.00024.66
8.3.00.0000.00826.16
8.2.290.0130.00617.50
8.2.280.0120.00818.23
8.2.270.0120.00617.16
8.2.260.0040.00422.48
8.2.250.0050.00316.73
8.2.240.0040.01516.91
8.2.230.0040.00422.58
8.2.220.0090.00037.54
8.2.210.0070.00726.77
8.2.200.0090.00018.42
8.2.190.0110.00716.58
8.2.180.0110.00418.29
8.2.170.0120.00318.68
8.2.160.0120.00322.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0070.00026.16
8.2.120.0040.00422.00
8.2.110.0030.00620.56
8.2.100.0090.00317.80
8.2.90.0040.00418.16
8.2.80.0040.00419.02
8.2.70.0130.00579.33
8.2.60.0110.00779.33
8.2.50.0150.00379.33
8.2.40.0130.00379.33
8.2.30.0130.00379.33
8.2.20.0080.00879.33
8.2.10.0120.00479.33
8.2.00.0100.00879.33
8.1.330.0120.00816.25
8.1.320.0070.00716.10
8.1.310.0030.00518.60
8.1.300.0070.00318.60
8.1.290.0060.00330.84
8.1.280.0120.00625.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00422.04
8.1.230.0110.00021.00
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0130.00379.33
8.1.190.0110.00579.33
8.1.180.0150.00279.33
8.1.170.0140.00379.33
8.1.160.0180.00579.33
8.1.150.0060.01279.33
8.1.140.0170.00079.33
8.1.130.0100.00779.33
8.1.120.0160.00079.33
8.1.110.0130.00379.33
8.1.100.0170.00079.33
8.1.90.0110.00479.33
8.1.80.0080.00879.33
8.1.70.0110.00679.33
8.1.60.0150.00479.33
8.1.50.0140.00579.33
8.1.40.0060.00379.33
8.1.30.0120.00679.33
8.1.20.0140.00379.33
8.1.10.0170.00079.33
8.1.00.0150.00479.33
8.0.300.0000.00820.23
8.0.290.0120.00479.33
8.0.280.0160.00079.33
8.0.270.0070.01079.33
8.0.260.0150.00279.33
8.0.250.0100.00779.33
8.0.240.0110.00679.33
8.0.230.0140.00379.33
8.0.220.0080.00879.33
8.0.210.0110.00579.33
8.0.200.0070.01079.33
8.0.190.0110.00579.33
8.0.180.0130.00379.33
8.0.170.0140.00579.33
8.0.160.0120.00479.33
8.0.150.0100.01379.33
8.0.140.0120.00779.33
8.0.130.0160.00079.33
8.0.120.0000.01679.33
8.0.110.0150.00079.33
8.0.100.0140.00279.33
8.0.90.0120.00479.33
8.0.80.0110.00579.33
8.0.70.0160.00079.33
8.0.60.0110.00579.33
8.0.50.0100.00779.33
8.0.30.0110.00679.33
8.0.20.0130.00479.33
8.0.10.0040.01279.33

preferences:
37.34 ms | 403 KiB | 5 Q