3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = ['legendaryName' => 'legendary_name']; $data = ['legendary_name' => 'The Hammer']; class Warrior { use DbHydrate; private $legendaryName; } trait DbHydrate { public function extract($config) { $row = []; foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $row[$column] = $this->{$attributeName}; } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } return $row; } public function hydrate($config, $data) { foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $this->{$attributeName} = $data[$column]; } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } } } $legendaryWarrior = new Warrior; $legendaryWarrior->hydrate($config, $data); var_dump($legendaryWarrior->extract($config)); var_dump($legendaryWarrior); /* $config = ['classicalName' => 'classical_name']; $data = ['classical_name' => 'John']; $testWarrior = new Warrior; $testWarrior->hydrate($config, $data); var_dump($testWarrior);*/

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.0170.00318.27
8.3.50.0150.00418.17
8.3.40.0100.00618.60
8.3.30.0110.00418.85
8.3.20.0080.00020.34
8.3.10.0080.00023.48
8.3.00.0030.00717.68
8.2.180.0110.00418.51
8.2.170.0160.00618.91
8.2.160.0070.01322.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0030.00620.91
8.2.110.0040.00722.12
8.2.100.0060.00617.78
8.2.90.0040.00417.73
8.2.80.0000.00819.25
8.2.70.0000.00818.16
8.2.60.0000.00818.05
8.2.50.0000.00818.34
8.2.40.0050.00320.59
8.2.30.0040.00419.36
8.2.20.0040.00418.00
8.2.10.0000.00818.02
8.2.00.0070.00018.36
8.1.280.0150.00025.92
8.1.270.0080.00022.11
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00322.60
8.1.230.0090.00320.96
8.1.220.0000.00817.74
8.1.210.0000.00918.77
8.1.200.0040.00417.48
8.1.190.0000.00817.13
8.1.180.0030.00618.10
8.1.170.0040.00418.64
8.1.160.0000.00718.95
8.1.150.0040.00420.30
8.1.140.0040.00417.72
8.1.130.0060.00319.07
8.1.120.0040.00417.50
8.1.110.0020.00517.46
8.1.100.0000.00817.47
8.1.90.0080.00017.36
8.1.80.0000.00817.50
8.1.70.0000.00717.41
8.1.60.0000.00717.51
8.1.50.0040.00417.50
8.1.40.0050.00217.39
8.1.30.0000.00817.54
8.1.20.0060.00317.63
8.1.10.0000.00717.46
8.1.00.0030.00517.57
8.0.300.0000.00822.04
8.0.290.0000.00816.75
8.0.280.0000.00718.46
8.0.270.0070.00017.21
8.0.260.0000.00616.75
8.0.250.0000.00616.87
8.0.240.0000.00816.87
8.0.230.0050.00316.96
8.0.220.0040.00416.82
8.0.210.0030.00316.88
8.0.200.0040.00416.89
8.0.190.0030.00717.01
8.0.180.0040.00416.91
8.0.170.0040.00416.95
8.0.160.0000.00716.94
8.0.150.0000.00716.86
8.0.140.0050.00316.87
8.0.130.0060.00013.30
8.0.120.0000.00716.88
8.0.110.0080.00016.89
8.0.100.0080.00016.88
8.0.90.0000.00816.76
8.0.80.0090.00616.92
8.0.70.0000.00716.89
8.0.60.0000.00716.93
8.0.50.0040.00416.76
8.0.30.0100.00816.98
8.0.20.0130.00917.40
8.0.10.0040.00416.93
8.0.00.0100.01116.66
7.4.330.0030.00315.55
7.4.320.0070.00016.58
7.4.300.0070.00016.52
7.4.290.0000.00716.52
7.4.280.0040.00416.61
7.4.270.0070.00016.69
7.4.260.0080.00016.53
7.4.250.0030.00316.48
7.4.240.0070.00016.43
7.4.230.0000.00716.45
7.4.220.0070.00016.27
7.4.210.0080.00916.53
7.4.200.0070.00016.43
7.4.160.0080.00916.69
7.4.150.0090.00917.40
7.4.140.0100.00917.86
7.4.130.0100.00716.52
7.4.120.0090.01116.59
7.4.110.0130.00516.50
7.4.100.0100.01316.49
7.4.90.0140.00316.48
7.4.80.0060.01519.39
7.4.70.0230.00016.69
7.4.60.0060.01016.58
7.4.50.0000.01816.52
7.4.40.0110.00716.38
7.4.00.0060.00915.09
7.3.330.0060.00013.39
7.3.320.0050.00013.19
7.3.310.0000.00716.40
7.3.300.0020.00516.39
7.3.290.0040.01116.41
7.3.280.0100.00616.37
7.3.270.0120.00617.40
7.3.260.0120.00616.48
7.3.240.0070.01016.45
7.3.230.0100.00716.57
7.3.210.0100.00516.39
7.3.200.0090.00616.62
7.3.190.0030.01316.39
7.3.180.0030.01316.69
7.3.170.0090.00616.46
7.3.160.0030.01216.35
7.3.120.0000.01714.79
7.3.110.0030.01015.12
7.3.100.0030.00914.57
7.3.90.0110.00314.62
7.3.80.0060.00915.01
7.3.70.0070.00714.72
7.3.60.0030.01014.87
7.3.50.0130.00314.96
7.3.40.0000.01714.83
7.3.30.0060.00914.91
7.3.20.0030.01316.66
7.3.10.0060.00916.78
7.3.00.0070.00716.75
7.2.330.0140.00316.82
7.2.320.0100.00716.50
7.2.310.0130.00716.84
7.2.300.0100.01416.45
7.2.290.0090.00816.65
7.2.240.0110.00314.94
7.2.230.0120.00614.98
7.2.220.0030.01015.26
7.2.210.0060.00615.25
7.2.200.0110.00715.12
7.2.190.0000.01315.11
7.2.180.0070.01014.87
7.2.170.0070.00715.09
7.2.160.0070.00315.07
7.2.150.0090.00616.86
7.2.140.0000.01616.61
7.2.130.0120.00316.82
7.2.120.0070.01016.86
7.2.110.0070.01016.72
7.2.100.0000.01316.97
7.2.90.0100.00716.92
7.2.80.0100.00617.01
7.2.70.0040.00816.89
7.2.60.0100.00616.89
7.2.50.0100.00716.91
7.2.40.0070.00717.03
7.2.30.0060.00916.88
7.2.20.0540.01117.23
7.2.10.0440.01117.44
7.2.00.0530.00717.55
7.1.330.0130.00315.91
7.1.320.0030.00915.91
7.1.310.0100.00315.80
7.1.300.0100.00715.62
7.1.290.0030.01315.86
7.1.280.0060.00615.87
7.1.270.0090.00615.85
7.1.260.0040.01115.75
7.1.250.0030.01015.91
7.1.200.0040.01115.79
7.1.140.0710.00416.76
7.1.130.0760.01616.90
7.1.120.0850.00917.14
7.1.110.0580.01916.47
7.1.100.0380.01316.20
7.1.90.0570.01516.03
7.1.80.0110.00815.71
7.1.70.0660.01015.49
7.1.60.0660.00633.02
7.1.50.0760.00733.16
7.1.40.0630.02232.79
7.1.30.0860.00732.61
7.1.20.0630.01732.76
7.1.10.0430.00714.85
7.1.00.0450.01314.79

preferences:
58.06 ms | 401 KiB | 5 Q