3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LegacyBank { protected $clients; protected $balances; public function __construct($clients, $balances) { $this->clients = $clients; $this->balances = $balances; } public function getClientIndex($name) { foreach ($clients as $key => $client) { if ($client == $name) { $id = $key; break; } } return $id; } public function getBalance($index) { return $this->balances[$index]; } public function setBalance($index, $value) { $this->balances[$index] = $value; } public function processTransfer($id1, $sum, $id2) { $this->balances[$id1] = $this->balances[$id1] - $sum; $this->balances[$id2] = $this->balances[$id2] + $sum; } } interface POOClient{ public function deposit($sum); public function verifyAccount(); public function transfer($sum, $destination); } class SimpleClient implements POOClient{ protected $name; protected $legacyBank; protected $index; public function __construct($name, $legacyBank) { $this->name = $name; $this->legacyBank = $legacyBank; $this->index = $legacyBank->getClient($name); } public function deposit($sum) { $legacybank->setBalance($this->index, $sum); } public function verifyAccount() { $sum = $legacyBank->getBalance($this->index); return $sum; } public function transfer($sum, $destination) { $toIndex = $legacyBank->getClient($destination); $this->legacyBank->setBalance($toIndex, $sum); $oldBalance = $this->legacybank->getBalance($this->index); $this->legacyBank->setBalance($this->index, $oldBalance - $sum); } } $clients = array( '0' => 'Ion', '1' => 'Maria', '2' => 'Costel' ); $balances = array( '0' => 1000, '1' => 1400, '2' => 1300 ); $legacyBank = new LegacyBank($clients, $balances); $clientObject = new SimpleClient('Ion', $legacyBank); print_t($clientObject);

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.0140.00416.75
8.3.50.0100.00821.97
8.3.40.0040.01118.85
8.3.30.0150.00019.02
8.3.20.0060.00320.29
8.3.10.0000.00823.66
8.3.00.0030.00519.38
8.2.180.0090.01218.57
8.2.170.0100.01022.96
8.2.160.0100.00320.57
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00717.75
8.2.120.0000.00826.35
8.2.110.0080.00322.08
8.2.100.0090.00318.04
8.2.90.0000.00819.10
8.2.80.0030.00517.97
8.2.70.0060.00317.63
8.2.60.0000.00817.91
8.2.50.0050.00318.07
8.2.40.0000.01019.25
8.2.30.0040.00420.70
8.2.20.0000.00917.79
8.2.10.0040.00418.13
8.2.00.0070.00018.14
8.1.280.0090.00625.92
8.1.270.0030.00623.99
8.1.260.0030.01328.09
8.1.250.0040.00428.09
8.1.240.0100.00722.66
8.1.230.0070.00417.66
8.1.220.0000.00817.77
8.1.210.0040.00418.77
8.1.200.0100.00017.35
8.1.190.0040.00417.25
8.1.180.0040.00418.10
8.1.170.0040.00418.59
8.1.160.0050.00221.97
8.1.150.0060.00318.95
8.1.140.0040.00419.46
8.1.130.0040.00417.67
8.1.120.0000.00817.44
8.1.110.0040.00417.36
8.1.100.0000.00717.48
8.1.90.0080.00017.37
8.1.80.0030.00617.46
8.1.70.0000.00817.55
8.1.60.0110.00017.57
8.1.50.0040.00417.54
8.1.40.0000.00817.51
8.1.30.0060.00317.59
8.1.20.0050.00317.54
8.1.10.0050.00317.48
8.1.00.0040.00417.55
8.0.300.0060.00318.77
8.0.290.0040.00416.88
8.0.280.0040.00418.48
8.0.270.0070.00017.36
8.0.260.0000.00617.28
8.0.250.0040.00417.04
8.0.240.0000.00717.07
8.0.230.0000.00717.02
8.0.220.0050.00216.93
8.0.210.0030.00316.98
8.0.200.0000.00916.93
8.0.190.0030.00517.02
8.0.180.0040.00416.95
8.0.170.0030.00617.02
8.0.160.0070.00017.01
8.0.150.0040.00416.88
8.0.140.0060.00316.91
8.0.130.0030.00613.36
8.0.120.0040.00416.91
8.0.110.0000.00716.94
8.0.100.0000.01016.96
8.0.90.0050.00216.93
8.0.80.0060.00916.86
8.0.70.0040.00416.81
8.0.60.0040.00416.76
8.0.50.0000.00816.89
8.0.30.0120.00917.27
8.0.20.0080.01317.41
8.0.10.0040.00416.93
8.0.00.0080.01016.77
7.4.330.0030.00315.09
7.4.320.0000.00616.53
7.4.300.0030.00316.44
7.4.290.0000.00716.54
7.4.280.0040.00416.51
7.4.270.0030.00616.60
7.4.260.0080.00316.56
7.4.250.0040.00416.63
7.4.240.0050.00316.52
7.4.230.0030.00316.51
7.4.220.0070.01016.55
7.4.210.0050.01016.56
7.4.200.0040.00416.55
7.4.160.0080.00816.73
7.4.150.0090.00917.40
7.4.140.0110.01217.86
7.4.130.0170.00316.55
7.4.120.0150.00316.46
7.4.110.0120.00616.64
7.4.100.0130.01016.55
7.4.90.0150.00316.43
7.4.80.0100.01019.39
7.4.70.0080.01016.68
7.4.60.0100.00716.61
7.4.50.0050.00316.64
7.4.40.0150.00316.61
7.4.30.0190.00316.54
7.4.00.0060.00914.94
7.3.330.0000.00713.34
7.3.320.0000.00513.38
7.3.310.0040.00416.28
7.3.300.0070.00016.34
7.3.290.0040.00416.20
7.3.280.0100.00616.37
7.3.270.0040.01317.40
7.3.260.0150.00316.52
7.3.250.0120.00616.48
7.3.240.0090.00816.46
7.3.230.0100.00716.46
7.3.210.0180.00016.41
7.3.200.0130.00316.48
7.3.190.0140.01116.52
7.3.180.0070.01016.59
7.3.170.0130.01016.47
7.3.160.0030.01616.43
7.2.330.0170.00716.77
7.2.320.0090.00916.54
7.2.310.0060.01216.86
7.2.300.0110.00616.41
7.2.290.0080.01116.56
7.2.60.0030.01116.83
7.2.00.0060.00619.49
7.1.200.0030.01015.55
7.1.100.0030.01017.89
7.1.70.0000.01116.78
7.1.60.0030.02019.48
7.1.50.0140.01016.82
7.1.00.0070.07322.44
7.0.200.0440.00714.48
7.0.60.0030.04019.85
7.0.50.0070.08317.91
7.0.40.0030.04320.27
7.0.30.0400.06720.25
7.0.20.0370.07720.08
7.0.10.0070.04020.25
7.0.00.0000.04720.22
5.6.280.0000.05020.95
5.6.210.0100.04020.80
5.6.200.0070.08018.19
5.6.190.0000.04320.63
5.6.180.0100.04720.63
5.6.170.0200.05020.47
5.6.160.0030.07720.61
5.6.150.0030.07718.19
5.6.140.0070.05318.15
5.6.130.0000.05718.15
5.6.120.0230.07321.16
5.6.110.0100.04021.00
5.6.100.0100.08321.03
5.6.90.0100.03721.12
5.6.80.0130.06720.49
5.5.350.4100.03720.34
5.5.340.0130.06317.98
5.5.330.0070.08020.29
5.5.320.0300.07320.34
5.5.310.0330.08320.35
5.5.300.0100.06317.94
5.5.290.0070.07717.93
5.5.280.0130.04020.98
5.5.270.0100.07720.89
5.5.260.0030.04320.88
5.5.250.0200.07720.50
5.5.240.0300.05720.21

preferences:
39.55 ms | 401 KiB | 5 Q