3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { public $val; public $next; public function __construct($val, $next) { $this->val = $val; $this->next = $next; } public function __toString() { $a = []; $c = $this; while ($c != null) { $a[] = $c->val; $c = $c->next; } return implode(", ", $a)."\n"; } public static function reverse($list) { $newl = null; $curr = $list; while ($curr != null) { $next = $curr->next; $curr->next = $newl; $newl = $curr; $curr = $next; } return $newl; } } $list = new Node(1, new Node(2, new Node(3, new Node(4, new Node(5, null))))); echo $list; $list = Node::reverse($list); echo $list; exit();

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.3.60.0110.01116.47
8.3.50.0100.00316.58
8.3.40.0040.01118.82
8.3.30.0070.01018.79
8.3.20.0040.00419.98
8.3.10.0040.00423.52
8.3.00.0070.00417.50
8.2.180.0100.00716.63
8.2.170.0060.00922.96
8.2.160.0170.00320.34
8.2.150.0060.00324.18
8.2.140.0070.00024.66
8.2.130.0080.00319.39
8.2.120.0080.00026.35
8.2.110.0040.00721.03
8.2.100.0110.00018.09
8.2.90.0040.00419.22
8.2.80.0090.00018.16
8.2.70.0000.00817.50
8.2.60.0060.00317.93
8.2.50.0030.00518.10
8.2.40.0030.00620.59
8.2.30.0030.00621.12
8.2.20.0000.00718.02
8.2.10.0040.00418.14
8.2.00.0000.00818.06
8.1.280.0030.01325.92
8.1.270.0040.00422.03
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00724.02
8.1.230.0070.00318.90
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0000.00917.36
8.1.190.0030.00517.13
8.1.180.0000.00818.10
8.1.170.0030.00518.55
8.1.160.0000.00719.08
8.1.150.0050.00320.63
8.1.140.0070.00019.73
8.1.130.0030.00318.97
8.1.120.0050.00317.38
8.1.110.0000.00817.48
8.1.100.0040.00417.51
8.1.90.0000.01117.28
8.1.80.0030.00317.38
8.1.70.0040.00417.39
8.1.60.0050.00317.59
8.1.50.0040.00417.43
8.1.40.0040.00417.43
8.1.30.0030.00617.70
8.1.20.0000.00817.50
8.1.10.0030.00517.54
8.1.00.0000.00717.54
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0000.00718.47
8.0.270.0030.00317.15
8.0.260.0060.00016.78
8.0.250.0000.00617.06
8.0.240.0030.00317.00
8.0.230.0070.00017.07
8.0.220.0030.00317.00
8.0.210.0040.00417.00
8.0.200.0030.00317.07
8.0.190.0000.01017.10
8.0.180.0000.00816.88
8.0.170.0050.00217.00
8.0.160.0000.00816.93
8.0.150.0000.00716.99
8.0.140.0000.00716.82
8.0.130.0050.00013.47
8.0.120.0040.00416.84
8.0.110.0050.00316.97
8.0.100.0070.00017.09
8.0.90.0000.00717.02
8.0.80.0070.01616.93
8.0.70.0070.00017.02
8.0.60.0050.00217.00
8.0.50.0040.00417.04
8.0.30.0060.01317.19
8.0.20.0110.01217.40
8.0.10.0000.00717.05
8.0.00.0100.00716.82
7.4.330.0030.00215.55
7.4.320.0030.00316.42
7.4.300.0030.00316.45
7.4.290.0080.00316.63
7.4.280.0040.00416.62
7.4.270.0030.00316.47
7.4.260.0050.00013.22
7.4.250.0040.00416.47
7.4.240.0000.00716.38
7.4.230.0040.00416.61
7.4.220.0060.01516.62
7.4.210.0030.01716.60
7.4.200.0040.00416.71
7.4.160.0100.00816.60
7.4.150.0120.00617.40
7.4.140.0130.00717.86
7.4.130.0030.01616.47
7.4.120.0110.00716.52
7.4.110.0180.00616.64
7.4.100.0130.00316.67
7.4.90.0060.01216.51
7.4.80.0100.00619.39
7.4.70.0060.01216.54
7.4.60.0030.01216.66
7.4.50.0070.01016.65
7.4.40.0190.00416.33
7.4.30.0080.00816.67
7.4.00.0030.01214.92
7.3.330.0060.00013.27
7.3.320.0050.00013.26
7.3.310.0050.00316.42
7.3.300.0000.00716.45
7.3.290.0040.00316.32
7.3.280.0080.00916.44
7.3.270.0090.00917.40
7.3.260.0170.00216.58
7.3.250.0060.01116.46
7.3.240.0130.01016.44
7.3.230.0080.00816.42
7.3.210.0060.01016.47
7.3.200.0110.00916.47
7.3.190.0070.01016.68
7.3.180.0160.00016.63
7.3.170.0040.01616.36
7.3.160.0090.01216.61
7.3.10.0030.01016.41
7.3.00.0040.01116.71
7.2.330.0120.00916.72
7.2.320.0060.01116.70
7.2.310.0090.00916.75
7.2.300.0070.01016.77
7.2.290.0100.00616.51
7.2.130.0000.01017.01
7.2.120.0030.01216.70
7.2.110.0030.01316.77
7.2.100.0130.00016.91
7.2.90.0080.00616.79
7.2.80.0100.00716.98
7.2.70.0100.00717.07
7.2.60.0050.01116.96
7.2.50.0100.00717.09
7.2.40.0030.01216.86
7.2.30.0130.00316.72
7.2.20.0060.00916.78
7.2.10.0070.00716.89
7.2.00.0070.00716.96
7.1.250.0090.00615.71
7.1.200.0070.00316.04
7.1.70.0030.01017.13
7.1.60.0130.01334.77
7.1.50.0250.00434.50
7.1.40.0330.01334.43
7.1.30.0170.02334.33
7.1.20.0270.01534.40
7.1.10.0080.01216.68
7.1.00.0090.00616.73
7.0.200.0030.01216.89
7.0.190.0080.00816.82
7.0.180.0030.02016.27
7.0.170.0080.01416.14
7.0.160.0140.00316.27
7.0.150.0060.00916.20
7.0.140.0120.00316.31
7.0.130.0090.00616.56
7.0.120.0040.01116.44
7.0.110.0000.01516.10
7.0.100.0040.01116.55
7.0.90.0040.01116.32
7.0.80.0060.00916.46
7.0.70.0080.00516.29
7.0.60.0090.00616.25
7.0.50.0040.01116.57
7.0.40.0070.00716.47
7.0.30.0030.01116.54
7.0.20.0030.01416.37
7.0.10.0030.01216.18
7.0.00.0100.01016.25

preferences:
51.08 ms | 401 KiB | 5 Q