3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Nil {} class Leaf { public function __construct(public int $value) {} } class Node { public function __construct(public Tree $left, public Tree $right) {} } class Tree { public function __construct(public Nil|Leaf|Node $val) {} } function depth(Tree $tree): int { $val = $tree->val; return match ($val::class) { Nil::class => 0, Leaf::class => 1, Node::class => 1 + max(depth($val->left), depth($val->right)), }; } $treeExample = new Tree(new Node( new Tree(new Leaf(5)), new Tree(new Node( new Tree(new Node( new Tree(new Nil()), new Tree(new Leaf(2)), )), new Tree(new Nil()), )) )); print depth($treeExample);

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.20.0140.00719.68
8.4.10.0090.00017.59
8.3.150.0090.00916.59
8.3.140.0070.01116.48
8.3.130.0100.00018.16
8.3.120.0040.01418.88
8.3.110.0040.00420.94
8.3.100.0060.00324.06
8.3.90.0100.00726.77
8.3.80.0040.00416.75
8.3.70.0100.00618.43
8.3.60.0140.00018.30
8.3.50.0120.00824.62
8.3.40.0060.01221.83
8.3.30.0090.00618.84
8.3.20.0050.00324.18
8.3.10.0050.00324.66
8.3.00.0080.00026.16
8.2.260.0130.00617.08
8.2.250.0030.00716.57
8.2.240.0060.00317.26
8.2.230.0050.00522.58
8.2.220.0090.00037.54
8.2.210.0060.01226.77
8.2.200.0090.00616.63
8.2.190.0030.01216.63
8.2.180.0000.01425.92
8.2.170.0120.00319.14
8.2.160.0100.00722.96
8.2.150.0040.00425.66
8.2.140.0070.01024.66
8.2.130.0000.00726.16
8.2.120.0060.00319.38
8.2.110.0030.00620.34
8.2.100.0070.00320.43
8.1.310.0070.01016.84
8.1.300.0090.00016.78
8.1.290.0060.00618.88
8.1.280.0120.00325.92
8.1.270.0070.00023.99
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0090.00020.77
8.1.230.0100.00020.44
8.0.00.0300.00816.76
7.4.130.0260.00416.41
7.4.120.0250.00716.51
7.4.110.0180.01116.33
7.4.100.0210.00816.18
7.4.90.0220.00616.19
7.4.80.0170.01316.36
7.4.70.0270.00416.37
7.4.60.0210.01416.20
7.4.50.0200.00916.27
7.4.40.0220.01116.50
7.4.30.0270.00316.20
7.4.20.0260.00316.38
7.4.10.0220.01016.30
7.4.00.0110.00716.48
7.3.250.0250.00716.28
7.3.240.0130.01716.06
7.3.230.0190.01316.31
7.3.220.0220.00816.07
7.3.210.0250.00616.21
7.3.200.0160.01316.32
7.3.190.0240.00616.22
7.3.180.0280.00516.35
7.3.170.0140.01816.31
7.3.160.0180.01416.18
7.3.150.0280.00616.18
7.3.140.0250.00616.05
7.3.130.0260.01016.13
7.3.120.0210.01316.25
7.3.110.0320.00016.22
7.3.100.0270.00616.27
7.3.90.0220.00616.09
7.3.80.0280.00316.15
7.3.70.0220.00916.13
7.3.60.0220.00716.16
7.3.50.0310.00015.93
7.3.40.0220.01016.12
7.3.30.0230.00616.16
7.3.20.0240.01216.16
7.3.10.0350.00316.29
7.3.00.0260.00516.11

preferences:
58.75 ms | 403 KiB | 5 Q