3v4l.org

run code in 300+ PHP versions simultaneously
<?php $combos = [ //Test case 1: normally written. ['FirstClass_1', 'FirstClass_2', 'FirstClass_3'], //Test case 2: swapped 'l' with 'C' inside 'FirstClass_1' to make it 'FirstlCass1'. ['FirstlCass_1', 'FirstClass_2', 'FirstClass_3'], //Test case 3: swapped positions. ['FirstClass_2', 'FirstClass_3', 'FirstlCass_1'] ]; class Node{ public $val; public $children; public $end_of_data; function __construct($val){ $this->val = $val; $this->children = []; $this->end_of_data = false; } } class DataManager{ private $root; private const INSERTED = 1; private const EXISTS = 2; function __construct(){ $this->root = new Node('~'); } public function putIfAbsent($data){ sort($data); // to make different combinations/anagrams of same values as one $node = $this->root; $status = self::EXISTS; foreach($data as $value){ if(!isset($node->children[$value])){ $node->children[$value] = new Node($value); $status = self::INSERTED; } $node = $node->children[$value]; } $node->end_of_data = true; return $status; } } $o = new DataManager(); foreach($combos as $combo){ var_dump($o->putIfAbsent($combo)); }

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.0070.01018.56
8.3.50.0090.00616.59
8.3.40.0070.01418.98
8.3.30.0080.00318.66
8.3.20.0000.00821.00
8.3.10.0040.00420.24
8.3.00.0040.00420.81
8.2.180.0070.01118.54
8.2.170.0060.00922.96
8.2.160.0050.00820.58
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0080.00021.07
8.2.110.0030.00922.25
8.2.100.0090.00618.05
8.2.90.0000.00919.38
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0040.00417.63
8.2.50.0040.00418.05
8.2.40.0050.00318.05
8.2.30.0030.00319.31
8.2.20.0030.00518.18
8.2.10.0000.00719.32
8.2.00.0070.00019.23
8.1.280.0070.00725.92
8.1.270.0080.00020.76
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00320.73
8.1.230.0090.00917.63
8.1.220.0060.00317.79
8.1.210.0050.00318.77
8.1.200.0030.00917.64
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0080.00017.62
8.1.160.0070.00019.02
8.1.150.0050.00219.02
8.1.140.0040.00418.88
8.1.130.0000.00720.14
8.1.120.0000.00717.48
8.1.110.0040.00417.43
8.1.100.0050.00317.35
8.1.90.0000.00717.52
8.1.80.0060.00317.43
8.1.70.0040.00417.38
8.1.60.0040.00417.54
8.1.50.0040.00417.52
8.1.40.0040.00417.48
8.1.30.0080.00017.70
8.1.20.0000.00717.61
8.1.10.0040.00417.59
8.1.00.0040.00417.55
8.0.300.0000.00818.77
8.0.290.0000.00716.63
8.0.280.0000.00718.52
8.0.270.0030.00318.01
8.0.260.0060.00020.07
8.0.250.0030.00316.97
8.0.240.0000.00716.80
8.0.230.0030.00317.00
8.0.220.0030.00316.97
8.0.210.0030.00516.76
8.0.200.0000.00816.85
8.0.190.0050.00216.92
8.0.180.0040.00416.81
8.0.170.0030.00616.90
8.0.160.0000.00716.85
8.0.150.0040.00416.72
8.0.140.0040.00416.74
8.0.130.0060.00013.30
8.0.120.0000.00816.89
8.0.110.0040.00416.84
8.0.100.0040.00416.93
8.0.90.0090.00016.93
8.0.80.0080.01216.90
8.0.70.0000.00716.78
8.0.60.0000.00716.76
8.0.50.0040.00416.88
8.0.30.0030.01417.21
8.0.20.0060.01216.81
8.0.10.0040.00416.82
8.0.00.0090.01817.02
7.4.330.0050.00015.55
7.4.320.0040.00416.61
7.4.300.0040.00416.64
7.4.290.0040.00416.42
7.4.280.0080.00016.52
7.4.270.0000.00716.54
7.4.260.0030.00313.27
7.4.250.0000.00716.57
7.4.240.0030.00516.52
7.4.230.0000.00716.67
7.4.220.0000.00716.54
7.4.210.0090.00816.54
7.4.200.0030.00516.72
7.4.130.0120.00516.44
7.4.120.0130.00316.42
7.4.110.0120.00616.60
7.4.100.0070.01016.47
7.4.90.0150.01216.58
7.4.80.0160.00619.39
7.4.70.0090.01216.56
7.4.60.0180.00516.63
7.4.50.0110.00416.39
7.4.40.0100.00616.36
7.4.20.0040.01516.36
7.4.10.0120.00616.38
7.4.00.0090.01216.51
7.3.330.0040.00416.46
7.3.320.0000.00513.39
7.3.310.0040.00416.33
7.3.300.0030.00316.38
7.3.290.0090.01016.38
7.3.280.0070.01116.27
7.3.260.0100.00716.69
7.3.240.0100.00716.47
7.3.230.0030.01416.56
7.3.210.0030.01316.52
7.3.200.0090.01216.40
7.3.190.0100.00716.66
7.3.180.0060.01116.59
7.3.170.0090.00716.51
7.3.160.0140.00416.47
7.3.140.0120.00616.57
7.3.130.0060.00916.69
7.3.120.0120.00916.38
7.3.110.0000.02016.36
7.3.100.0110.00716.36
7.3.90.0120.00916.41
7.3.80.0170.00416.57
7.3.70.0100.01016.38
7.3.60.0090.01216.39
7.3.50.0070.01016.49
7.3.40.0070.01416.37
7.3.30.0030.01316.43
7.3.20.0100.01016.50
7.3.10.0090.00616.38
7.3.00.0100.01316.33
7.2.330.0130.01016.50
7.2.320.0100.00716.37
7.2.310.0030.01316.58
7.2.300.0100.01316.90
7.2.290.0030.01316.92
7.2.270.0080.01116.75
7.2.260.0000.02016.77
7.2.250.0100.01016.69
7.2.240.0030.01616.85
7.2.230.0160.00616.67
7.2.220.0100.01016.75
7.2.210.0140.00316.43
7.2.200.0080.01216.66
7.2.190.0080.01116.55
7.2.180.0040.01616.63
7.2.170.0100.00616.57
7.2.160.0090.00816.55
7.2.150.0120.00916.70
7.2.140.0130.00916.67
7.2.130.0150.00916.67
7.2.120.0140.00316.49
7.2.110.0150.00316.75
7.2.100.0090.01516.78
7.2.90.0070.01616.82
7.2.80.0030.02116.67
7.2.70.0100.01316.90
7.2.60.0120.01216.61
7.2.50.0090.01316.79
7.2.40.0070.01416.43
7.2.30.0160.00616.61
7.2.20.0030.01716.58
7.2.10.0040.01216.60
7.2.00.0030.01416.56

preferences:
65.6 ms | 401 KiB | 5 Q