3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataHolder { private $rawData; private $parsedData; private $mapping = [ 'dbField1' => 'outputField1', 'dbField2' => ['outputField2' => ['parseFn1', 'parseFn2']] ]; private function parserFn1($value) { return $value * 2; } private function parserFn2($value) { return $value . "$"; } public function __construct(array $data) { $this->rawData = $data; $this->mapData(); } // Yes, I know the methods shouldn't be here but it rather be decoupled in another class and // injected with a DI it but I wrote it like this with example purposes only private function mapData() { foreach($this->mapping as $dbFieldName => $content) { if(isset($this->rawData[$dbFieldName])) { if(is_string($content)) { $parsedData[$content] = $this->rawData[$dbFieldName]; } else if (is_array($content)) { $frontFieldName = key($content); $functionsArray = reset($content); $value = $this->rawData[$dbFieldName]; foreach($functionsArray as $functionName) { if(method_exists(DataHolder::class, $functionName)) { var_dump($functionName); } } } } } } } $data = ['dbField1' => 5, 'dbField2' => 13]; $dh = new DataHolder($data);

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.30
8.3.50.0150.00522.18
8.3.40.0100.00718.88
8.3.30.0110.00419.02
8.3.20.0080.00020.34
8.3.10.0040.00420.53
8.3.00.0000.00819.30
8.2.180.0040.01125.92
8.2.170.0140.00322.96
8.2.160.0030.01320.33
8.2.150.0070.00024.18
8.2.140.0070.00024.66
8.2.130.0050.00226.16
8.2.120.0040.00422.08
8.2.110.0030.00719.21
8.2.100.0000.01217.97
8.2.90.0060.00319.21
8.2.80.0050.00317.97
8.2.70.0030.00617.63
8.2.60.0000.00918.05
8.2.50.0030.00618.07
8.2.40.0030.00618.16
8.2.30.0040.00418.12
8.2.20.0050.00317.81
8.2.10.0040.00418.19
8.2.00.0000.00717.68
8.1.280.0130.00725.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00321.24
8.1.230.0040.00717.42
8.1.220.0080.00017.76
8.1.210.0000.00818.77
8.1.200.0030.00717.35
8.1.190.0030.00617.22
8.1.180.0030.00518.10
8.1.170.0080.00018.43
8.1.160.0040.00422.04
8.1.150.0000.00718.81
8.1.140.0000.00717.47
8.1.130.0050.00317.96
8.1.120.0000.00717.47
8.1.110.0040.00417.45
8.1.100.0040.00417.34
8.1.90.0030.00317.53
8.1.80.0040.00417.50
8.1.70.0030.00317.36
8.1.60.0080.00417.52
8.1.50.0050.00317.59
8.1.40.0000.00717.44
8.1.30.0030.00617.60
8.1.20.0040.00417.71
8.1.10.0000.00817.51
8.1.00.0060.00317.48
8.0.300.0000.00718.77
8.0.290.0030.00616.75
8.0.280.0030.00318.47
8.0.270.0040.00417.23
8.0.260.0070.00017.14
8.0.250.0000.00716.91
8.0.240.0000.00816.96
8.0.230.0040.00417.00
8.0.220.0070.00016.92
8.0.210.0000.00716.87
8.0.200.0000.00716.96
8.0.190.0080.00016.86
8.0.180.0070.00016.96
8.0.170.0040.00416.93
8.0.160.0040.00416.79
8.0.150.0000.00716.92
8.0.140.0030.00716.85
8.0.130.0060.00313.35
8.0.120.0040.00416.83
8.0.110.0050.00216.91
8.0.100.0070.00016.85
8.0.90.0000.00716.91
8.0.80.0070.01516.92
8.0.70.0000.00916.92
8.0.60.0000.00716.92
8.0.50.0030.00516.92
8.0.30.0180.00316.98
8.0.20.0100.00817.40
8.0.10.0060.00317.07
8.0.00.0130.00816.86
7.4.330.0020.00215.00
7.4.320.0060.00016.50
7.4.300.0040.00416.59
7.4.290.0050.00316.59
7.4.280.0030.00516.46
7.4.270.0030.00316.51
7.4.260.0030.00316.57
7.4.250.0060.00316.57
7.4.240.0040.00416.52
7.4.230.0030.00316.62
7.4.220.0050.01416.60
7.4.210.0090.00616.61
7.4.200.0070.00016.43
7.4.160.0100.00716.33
7.4.150.0100.00717.40
7.4.140.0060.01317.86
7.4.130.0140.00416.49
7.4.120.0120.00616.45
7.4.110.0140.00316.55
7.4.100.0060.01116.47
7.4.90.0060.01316.48
7.4.80.0100.01019.39
7.4.70.0060.01016.52
7.4.60.0090.01216.59
7.4.50.0020.00216.64
7.4.40.0170.00016.30
7.4.30.0090.01216.44
7.4.00.0100.00614.98
7.3.330.0030.00313.20
7.3.320.0020.00313.45
7.3.310.0000.00716.24
7.3.300.0050.00216.34
7.3.290.0060.01516.35
7.3.280.0060.00816.37
7.3.270.0120.00617.40
7.3.260.0070.01116.38
7.3.250.0080.01116.31
7.3.240.0030.01416.41
7.3.230.0080.00816.63
7.3.210.0100.00616.32
7.3.200.0130.01019.39
7.3.190.0060.01016.50
7.3.180.0060.01016.64
7.3.170.0130.00416.55
7.3.160.0060.01216.59
7.2.330.0110.00716.56
7.2.320.0090.00916.70
7.2.310.0100.00716.80
7.2.300.0090.00916.82
7.2.290.0130.00716.76
7.2.60.0070.00717.04
7.2.00.0070.00319.19
7.1.200.0030.01315.62
7.1.100.0070.00718.17
7.1.70.0040.00417.21
7.1.60.0100.01419.32
7.1.50.0120.00616.92
7.1.00.0030.07722.35
7.0.200.0070.00316.84
7.0.140.0030.06722.00
7.0.60.0030.07319.92
7.0.50.0030.08017.87
7.0.40.0030.05020.23
7.0.30.0470.07020.07
7.0.20.0230.04320.38
7.0.10.0330.07320.24
7.0.00.0100.08320.23
5.6.280.0070.06721.13
5.6.210.0100.07720.48
5.6.200.0100.08018.15
5.6.190.0100.04720.41
5.6.180.0000.08320.41
5.6.170.0330.04720.71
5.6.160.0100.08320.54
5.6.150.0030.08718.18
5.6.140.0030.04018.15
5.6.130.0170.06718.23
5.6.120.0000.04321.03
5.6.110.0100.08021.09
5.6.100.0170.08020.99
5.6.90.0130.08021.11
5.6.80.0100.08020.45
5.5.350.0030.08320.50
5.5.340.0030.04018.04
5.5.330.0100.05720.57
5.5.320.0070.07320.25
5.5.310.0400.06720.34
5.5.300.0070.07718.02
5.5.290.0070.08317.96
5.5.280.0030.09020.96
5.5.270.0100.07320.99
5.5.260.0100.07020.91
5.5.250.0100.07720.71
5.5.240.0170.06720.20
5.4.450.3330.04319.48
5.4.440.3770.03019.40
5.4.430.3570.04319.39
5.4.420.3670.03719.40
5.4.410.4170.03719.35
5.4.400.3970.03718.86
5.4.390.3470.03718.88
5.4.380.3530.04019.06
5.4.370.3470.04019.06
5.4.360.4230.04018.89
5.4.350.4330.03319.15
5.4.340.3630.03019.08
5.4.320.4270.04019.05
5.4.310.4200.04019.13
5.4.300.4630.02318.84
5.4.290.4400.03019.11
5.4.280.3430.03319.07
5.4.270.3600.04018.95
5.4.260.3700.04719.05
5.4.250.3800.03019.05
5.4.240.3430.03718.87
5.4.230.3770.03719.07
5.4.220.4270.03318.98
5.4.210.4270.04019.05
5.4.200.4330.03018.97
5.4.190.3670.04018.86
5.4.180.4200.02719.10
5.4.170.4070.04018.84
5.4.160.4130.04018.94
5.4.150.4370.03718.89
5.4.140.4170.03016.42
5.4.130.4200.03016.36
5.4.120.0070.05016.53
5.4.110.4370.03016.59
5.4.100.3800.03316.39
5.4.90.3930.03716.50
5.4.80.3470.02716.56
5.4.70.3770.03316.21
5.4.60.3800.03316.53
5.4.50.4270.03316.53
5.4.40.4230.03716.44
5.4.30.3200.04316.52
5.4.20.3470.02716.43
5.4.10.0070.03316.49
5.4.00.0030.03315.86
5.3.290.4470.04314.63
5.3.280.3800.03714.65
5.3.270.3500.03714.68
5.3.260.3970.03714.52
5.3.250.3970.03714.57
5.3.240.4400.02314.68
5.3.230.1370.04314.56
5.3.220.0070.04014.48
5.3.210.1300.06014.68
5.3.200.3870.04014.68
5.3.190.3730.03314.61
5.3.180.3830.03714.48
5.3.170.3170.02714.71
5.3.160.4270.04314.63
5.3.150.4130.03714.46
5.3.140.4200.04014.60
5.3.130.4530.04714.55
5.3.120.3530.03714.46
5.3.110.2470.03314.76
5.3.100.0030.04013.99
5.3.90.3330.04013.99
5.3.80.3670.03013.94
5.3.70.3400.03713.98
5.3.60.3370.03313.91
5.3.50.3900.04313.87
5.3.40.3570.03313.96
5.3.30.3230.03713.83
5.3.20.3300.03013.61
5.3.10.3670.03713.57
5.3.00.3570.04013.54
5.2.170.2570.02711.05
5.2.160.2600.02311.12
5.2.150.2800.02711.27
5.2.140.2830.02711.05
5.2.130.2770.02711.11
5.2.120.3100.02311.03
5.2.110.3130.03311.31
5.2.100.3000.03311.07
5.2.90.3030.02311.15
5.2.80.3330.02011.21
5.2.70.2970.03311.14
5.2.60.3670.03711.20
5.2.50.3830.03310.91
5.2.40.3030.03311.07
5.2.30.2930.02311.19
5.2.20.2500.02711.03
5.2.10.2870.03710.77
5.2.00.2970.02310.64
5.1.60.2930.02310.07
5.1.50.2800.0239.97
5.1.40.2470.0279.89
5.1.30.2530.03010.28
5.1.20.2330.02310.43
5.1.10.2570.0209.96
5.1.00.2230.02710.05
5.0.50.1370.0208.42
5.0.40.1100.0238.41
5.0.30.1400.0308.37
5.0.20.1300.0178.11
5.0.10.1330.0178.07
5.0.00.1200.0378.23
4.4.90.1370.0135.79
4.4.80.1430.0175.85
4.4.70.1500.0135.80
4.4.60.1130.0135.83
4.4.50.1070.0175.82
4.4.40.1470.0235.88
4.4.30.1400.0205.89
4.4.20.1130.0175.98
4.4.10.1170.0175.88
4.4.00.1270.0235.82
4.3.110.1330.0135.83
4.3.100.1100.0175.79
4.3.90.1100.0135.80
4.3.80.1370.0235.79
4.3.70.1370.0105.79
4.3.60.1330.0135.79
4.3.50.1300.0175.79
4.3.40.1570.0235.79
4.3.30.0800.0205.79
4.3.20.0870.0275.79
4.3.10.0930.0205.79
4.3.00.0900.0205.79

preferences:
49.87 ms | 401 KiB | 5 Q