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; } public static function reverseRecursively($list) { if ($list == null || $list->next == null) { return $list; } $next = $list->next; $list->next = null; $next = self::reverseRecursively($next); $next->next = $list; return $next; } } $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; $list = Node::reverseRecursively($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.0130.01016.75
8.3.50.0190.00016.52
8.3.40.0070.01118.79
8.3.30.0040.01118.84
8.3.20.0050.00220.30
8.3.10.0030.00721.69
8.3.00.0040.00421.97
8.2.180.0090.00916.75
8.2.170.0040.01122.96
8.2.160.0180.00419.08
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00420.94
8.2.120.0040.00426.35
8.2.110.0060.00320.52
8.2.100.0060.00617.97
8.2.90.0040.00419.40
8.2.80.0050.00317.97
8.2.70.0030.00617.63
8.2.60.0000.00817.93
8.2.50.0040.00418.10
8.2.40.0030.00620.55
8.2.30.0030.00621.10
8.2.20.0040.00418.18
8.2.10.0000.00718.16
8.2.00.0000.00918.08
8.1.280.0090.00625.92
8.1.270.0080.00022.18
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.89
8.1.230.0100.00317.70
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0040.00420.17
8.1.160.0070.00019.06
8.1.150.0000.00720.73
8.1.140.0000.00819.61
8.1.130.0000.00718.89
8.1.120.0030.00317.44
8.1.110.0040.00417.28
8.1.100.0040.00317.42
8.1.90.0000.00817.57
8.1.80.0000.00717.55
8.1.70.0000.00717.39
8.1.60.0000.00717.50
8.1.50.0000.00817.59
8.1.40.0000.00817.56
8.1.30.0000.00817.70
8.1.20.0040.00417.70
8.1.10.0080.00017.61
8.1.00.0040.00417.57
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0030.00318.48
8.0.270.0000.00717.29
8.0.260.0000.00916.83
8.0.250.0050.00316.94
8.0.240.0050.00217.05
8.0.230.0000.00717.08
8.0.220.0040.00416.94
8.0.210.0050.00216.88
8.0.200.0050.00217.10
8.0.190.0040.00416.94
8.0.180.0050.00316.99
8.0.170.0000.00816.94
8.0.160.0070.00416.81
8.0.150.0040.00416.82
8.0.140.0070.00016.86
8.0.130.0090.00013.38
8.0.120.0030.00516.97
8.0.110.0000.00817.04
8.0.100.0070.00016.89
8.0.90.0040.00417.06
8.0.80.0060.01616.95
8.0.70.0030.00516.82
8.0.60.0000.00816.79
8.0.50.0070.00016.95
8.0.30.0150.00517.18
8.0.20.0080.01217.40
8.0.10.0040.00417.11
8.0.00.0070.01016.79
7.4.330.0050.00015.55
7.4.320.0030.00316.54
7.4.300.0030.00316.63
7.4.290.0060.00016.52
7.4.280.0030.00516.62
7.4.270.0000.00716.52
7.4.260.0050.00316.63
7.4.250.0000.00716.59
7.4.240.0000.00716.69
7.4.230.0030.00316.73
7.4.220.0110.00816.65
7.4.210.0000.01316.65
7.4.200.0040.00416.63
7.4.160.0120.00716.42
7.4.150.0110.00717.40
7.4.140.0080.00917.86
7.4.130.0030.02116.49
7.4.120.0110.00916.44
7.4.110.0120.00616.70
7.4.100.0090.01316.54
7.4.90.0110.00516.61
7.4.80.0070.01019.39
7.4.70.0070.01016.66
7.4.60.0030.01316.61
7.4.50.0120.00316.40
7.4.40.0070.01116.64
7.4.30.0070.01116.56
7.4.00.0030.01314.95
7.3.330.0000.00513.38
7.3.320.0060.00013.32
7.3.310.0050.00316.45
7.3.300.0000.00616.29
7.3.290.0120.00416.49
7.3.280.0110.00916.45
7.3.270.0060.01017.40
7.3.260.0010.01516.64
7.3.250.0040.01616.51
7.3.240.0070.01016.51
7.3.230.0110.00716.64
7.3.210.0030.01216.46
7.3.200.0060.01216.43
7.3.190.0170.00616.43
7.3.180.0080.00816.39
7.3.170.0150.00616.40
7.3.160.0080.00816.55
7.2.330.0100.01016.80
7.2.320.0030.01316.71
7.2.310.0030.01516.69
7.2.300.0000.01716.71
7.2.290.0170.00616.75
7.2.60.0030.00617.01
7.2.00.0030.01419.37
7.1.200.0030.00615.45
7.1.100.6650.01315.57
7.1.70.0060.01217.20
7.1.60.0350.01435.18
7.1.50.0650.00632.98
7.1.40.0180.02234.34
7.1.30.0380.01134.70
7.1.20.0650.01634.61
7.1.10.0110.01016.65
7.1.00.0090.01316.71
7.0.200.0510.01916.73
7.0.190.0150.00316.56
7.0.180.0030.01816.34
7.0.170.0090.01116.23
7.0.160.0040.01716.20
7.0.150.0070.01316.21
7.0.140.0040.01716.37
7.0.130.0030.01816.29
7.0.120.0030.01716.63
7.0.110.0080.01516.35
7.0.100.0300.01916.54
7.0.90.0380.00816.40
7.0.80.0080.01516.61
7.0.70.0100.01616.09
7.0.60.0090.01316.16
7.0.50.0070.01316.26
7.0.40.0320.01316.43
7.0.30.0390.00716.69
7.0.20.0030.01716.63
7.0.10.0090.01216.37
7.0.00.0090.00916.31

preferences:
47.27 ms | 400 KiB | 5 Q