3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface BehaviorInterface {} abstract class BaseService { protected $behaviors; public function addBehavior(BehaviorInterface $b, array $export = []) { if (!count($this->behaviors)) { $this->behaviors[] = ['object' => $b, 'export' => $export]; return $this; } foreach ($this->behaviors as $behavior) { if (count($export) && count(array_intersect($behavior['export'], $export)) > 0) { throw new \Exception("Some of export methods already exists"); } $this->behaviors[] = ['object' => $b, 'export' => $export]; } return $this; } public function __call($name, $arguments) { foreach ($this->behaviors as $behavior) { if ((in_array($name, $behavior['export']) || !count($behavior['export'])) && method_exists($behavior['object'], $name)) { return call_user_func_array([$behavior['object'], $name], $arguments); } } $class = get_called_class(); throw new \Exception('Method "' . $name . '" does not exist in class "' . $class . '"'); } } class SayHui implements BehaviorInterface { public function hui($name) { echo $name, ', hui tebe!' . PHP_EOL; } } class NewSayHui implements BehaviorInterface { public function hui($name) { echo 'Fuck you, ' . $name . '!' . PHP_EOL; } } class HuiService extends BaseService { } class HuiService2 extends BaseService { } class HuiService3 extends BaseService { } $huiService = new HuiService(); $huiService->addBehavior(new SayHui(), ['hui']) ->hui('Nikita'); $huiService = new HuiService2(); $huiService->addBehavior(new NewSayHui(), ['hui']) ->hui('Eugene'); $huiService = new HuiService3(); $huiService->addBehavior(new SayHui()) ->addBehavior(new NewSayHui()) ->hui('Shandor');

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.0040.01116.74
8.3.50.0140.00522.05
8.3.40.0040.01118.76
8.3.30.0140.00418.84
8.3.20.0040.00420.20
8.3.10.0040.00423.48
8.3.00.0040.00419.85
8.2.180.0070.00718.29
8.2.170.0040.01122.96
8.2.160.0140.00420.39
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0030.00619.34
8.2.120.0030.00726.35
8.2.110.0000.00820.52
8.2.100.0090.00317.91
8.2.90.0040.00419.29
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0000.00918.05
8.2.50.0030.00618.07
8.2.40.0040.00421.20
8.2.30.0000.00720.52
8.2.20.0040.00417.78
8.2.10.0030.00518.04
8.2.00.0030.00617.98
8.1.280.0110.00425.92
8.1.270.0080.00018.84
8.1.260.0000.01028.09
8.1.250.0040.00428.09
8.1.240.0060.00323.72
8.1.230.0070.00420.74
8.1.220.0050.00317.74
8.1.210.0060.00318.77
8.1.200.0030.00617.22
8.1.190.0040.00417.53
8.1.180.0000.00818.10
8.1.170.0000.00818.59
8.1.160.0060.00320.87
8.1.150.0000.00718.93
8.1.140.0080.00019.58
8.1.130.0040.00417.62
8.1.120.0040.00417.50
8.1.110.0030.00517.52
8.1.100.0060.00317.46
8.1.90.0040.00417.40
8.1.80.0040.00417.47
8.1.70.0030.00317.50
8.1.60.0050.00217.59
8.1.50.0040.00417.57
8.1.40.0000.00817.59
8.1.30.0040.00417.67
8.1.20.0040.00417.70
8.1.10.0000.00717.54
8.1.00.0060.00317.45
8.0.300.0000.00718.77
8.0.290.0000.00716.88
8.0.280.0070.00018.41
8.0.270.0000.00717.18
8.0.260.0060.00017.21
8.0.250.0030.00317.02
8.0.240.0030.00317.05
8.0.230.0070.00017.04
8.0.220.0050.00216.83
8.0.210.0070.00016.91
8.0.200.0040.00417.07
8.0.190.0040.00417.05
8.0.180.0070.00017.02
8.0.170.0050.00317.02
8.0.160.0050.00316.89
8.0.150.0000.00716.96
8.0.140.0030.00416.96
8.0.130.0080.00013.34
8.0.120.0040.00416.88
8.0.110.0040.00416.91
8.0.100.0000.00717.02
8.0.90.0070.00016.86
8.0.80.0090.00616.96
8.0.70.0000.00716.95
8.0.60.0040.00416.95
8.0.50.0000.00716.80
8.0.30.0040.01117.34
8.0.20.0100.01017.41
8.0.10.0000.00717.14
8.0.00.0090.00916.79
7.4.330.0000.00516.66
7.4.320.0070.00016.58
7.4.300.0030.00316.41
7.4.290.0030.00316.62
7.4.280.0050.00216.67
7.4.270.0000.00816.48
7.4.260.0030.00316.57
7.4.250.0000.00716.46
7.4.240.0010.00616.52
7.4.230.0000.00716.72
7.4.220.0140.00716.67
7.4.210.0060.00916.57
7.4.200.0000.00716.30
7.4.160.0030.01316.73
7.4.150.0060.01217.40
7.4.140.0110.00917.86
7.4.130.0100.00716.59
7.4.120.0150.00816.52
7.4.110.0060.02116.73
7.4.100.0090.00916.59
7.4.90.0100.01316.64
7.4.80.0150.00319.39
7.4.70.0070.01416.55
7.4.60.0160.00316.70
7.4.50.0030.01016.29
7.4.40.0150.00716.44
7.4.30.0040.01916.59
7.4.00.0100.00314.93
7.3.330.0060.00013.48
7.3.320.0000.00613.34
7.3.310.0030.00316.46
7.3.300.0000.00816.39
7.3.290.0100.00516.45
7.3.280.0090.00816.51
7.3.270.0060.01217.40
7.3.260.0100.00716.52
7.3.250.0110.00816.49
7.3.240.0130.00716.42
7.3.230.0100.01316.39
7.3.210.0110.01116.52
7.3.200.0100.00716.37
7.3.190.0130.00316.80
7.3.180.0090.00816.52
7.3.170.0070.01016.59
7.3.160.0090.00816.49
7.2.330.0110.00716.91
7.2.320.0060.01216.86
7.2.310.0030.01316.88
7.2.300.0120.00616.52
7.2.290.0080.00816.46
7.2.60.0070.00716.64
7.2.00.0090.00319.33
7.1.200.0090.00615.85
7.1.100.0040.00817.88
7.1.70.0000.00717.27
7.1.60.0040.01819.50
7.1.50.0030.00917.05
7.1.00.0000.07722.27
7.0.200.0000.00916.89
7.0.100.0070.08319.93
7.0.90.0270.06319.96
7.0.80.0470.06320.00
7.0.70.0530.08020.06
7.0.60.0500.06020.11
7.0.50.0300.08320.46
7.0.40.0130.04320.07
7.0.30.0170.07320.09
7.0.20.0130.07020.07
7.0.10.0000.09319.95
7.0.00.0100.08320.13
5.6.280.0030.04321.06
5.6.250.0030.04320.61
5.6.240.0000.08320.65
5.6.230.0100.06320.51
5.6.220.0030.09020.57
5.6.210.0070.05020.63
5.6.200.0170.06321.04
5.6.190.0100.07021.05
5.6.180.0030.05321.20
5.6.170.0100.04720.96
5.6.160.0070.04720.96
5.6.150.0070.06321.16
5.6.140.0030.08720.96
5.6.130.0100.07721.11
5.6.120.0100.05721.13
5.6.110.0070.08721.04
5.6.100.0130.07320.95
5.6.90.0070.08721.01
5.6.80.0130.03020.36
5.6.70.0070.07720.34
5.6.60.0170.06020.35
5.6.50.0200.06320.43
5.6.40.0100.07720.46
5.6.30.0130.07320.56
5.6.20.0100.07720.34
5.6.10.0030.05320.46
5.6.00.0030.07720.50
5.5.380.0130.07720.55
5.5.370.0100.06720.38
5.5.360.0070.07720.45
5.5.350.0070.06720.34
5.5.340.0100.03720.88
5.5.330.0030.04320.76
5.5.320.0070.06320.79
5.5.310.0070.05020.78
5.5.300.0030.08320.95
5.5.290.0300.03020.91
5.5.280.0130.08020.78
5.5.270.0030.08720.79
5.5.260.0130.07320.78
5.5.250.0000.06020.72
5.5.240.0170.05720.31
5.5.230.0130.07720.17
5.5.220.0030.08020.28
5.5.210.0100.07720.18
5.5.200.0100.08020.25
5.5.190.0130.07720.14
5.5.180.0170.07020.22
5.5.160.0030.05020.20
5.5.150.0100.07720.30
5.5.140.0070.06720.13
5.5.130.0070.04020.01
5.5.120.0170.07020.27
5.5.110.0130.06720.23
5.5.100.0100.07720.11
5.5.90.0100.05020.16
5.5.80.0100.04720.12
5.5.70.0070.08320.11
5.5.60.0000.08020.11
5.5.50.0100.06720.03
5.5.40.0070.08320.08
5.5.30.0100.06020.08
5.5.20.0130.04320.08
5.5.10.0070.08020.09
5.5.00.0130.07020.04

preferences:
56.65 ms | 401 KiB | 5 Q