3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ConfigValueInterface { public function __toString(); } interface ConfigWriterInterface { public function write(ConfigValueInterface $value); } class WriteManager { protected $writers = []; public function addWriter(ConfigWriterInterface $writer, $value_class) { $this->writers[$value_class] = $writer; } public function write(ConfigValueInterface $value) { $class = get_class($value); if (isset($this->writers[$class])) { $this->writers[$class]->write($value); } } } class BaseConfigValue implements ConfigValueInterface { public $storage_location; public function __toString() { return "derp"; } } class NginxConfigValue extends BaseConfigValue {} class BaseConfigWriter implements ConfigWriterInterface { public function write(ConfigValueInterface $value) { if (!$value instanceof BaseConfigValue) { throw new \RuntimeException('Invalid value type'); } echo "writing to {$value->storage_location}\n"; } } class NginxConfigWriter implements ConfigWriterInterface { public function write(ConfigValueInterface $value) { if (!$value instanceof NginxConfigValue) { throw new \RuntimeException('Invalid value type'); } echo "writing NGINX config to {$value->storage_location}\n"; } } // Mock Value objects $nginx_value = new NginxConfigValue(); $base_value = new BaseConfigValue(); $nginx_value->storage_location = $base_value->storage_location = "/some/path"; // Set up manager $manager = new WriteManager(); $manager->addWriter(BaseConfigWriter::class, BaseConfigValue::class); $manager->addWriter(NginxConfigWriter::class, NginxConfigValue::class); $generator = new ExampleGenerator(); $value = $generator->generate(); $manager->write($value); $generator = new NginxGenerator(); $value = $generator->generate(); $manager->write($value);

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.88
8.3.50.0000.01517.80
8.3.40.0070.01318.88
8.3.30.0110.00418.70
8.3.20.0070.00020.19
8.3.10.0000.00823.57
8.3.00.0080.00019.91
8.2.180.0160.00018.25
8.2.170.0110.00722.96
8.2.160.0100.00320.32
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00419.31
8.2.120.0040.00426.35
8.2.110.0040.00720.57
8.2.100.0120.00017.93
8.2.90.0050.00319.28
8.2.80.0030.00517.97
8.2.70.0030.00617.61
8.2.60.0040.00417.93
8.2.50.0030.00518.07
8.2.40.0030.00622.28
8.2.30.0060.00320.54
8.2.20.0060.00317.64
8.2.10.0040.00417.98
8.2.00.0040.00418.06
8.1.280.0100.01025.92
8.1.270.0100.01020.25
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0040.00723.79
8.1.230.0000.01117.83
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0030.00717.47
8.1.190.0050.00317.23
8.1.180.0000.00818.10
8.1.170.0000.00818.59
8.1.160.0070.00020.66
8.1.150.0040.00418.97
8.1.140.0050.00219.47
8.1.130.0030.00317.68
8.1.120.0030.00517.54
8.1.110.0000.00717.30
8.1.100.0000.00817.45
8.1.90.0000.00817.50
8.1.80.0000.00717.47
8.1.70.0030.00617.50
8.1.60.0040.00417.67
8.1.50.0050.00517.55
8.1.40.0080.00017.58
8.1.30.0000.00817.61
8.1.20.0000.00717.71
8.1.10.0000.00817.44
8.1.00.0000.00717.44
8.0.300.0000.00718.77
8.0.290.0020.00516.62
8.0.280.0030.00318.33
8.0.270.0000.00717.32
8.0.260.0000.00617.19
8.0.250.0040.00416.93
8.0.240.0000.00616.90
8.0.230.0030.00316.93
8.0.220.0030.00316.93
8.0.210.0040.00416.89
8.0.200.0000.00717.04
8.0.190.0050.00217.04
8.0.180.0040.00417.02
8.0.170.0070.00017.00
8.0.160.0040.00417.06
8.0.150.0000.00816.90
8.0.140.0060.00316.88
8.0.130.0030.00313.39
8.0.120.0000.00916.79
8.0.110.0050.00316.90
8.0.100.0040.00416.85
8.0.90.0000.00716.87
8.0.80.0030.01316.93
8.0.70.0070.00016.96
8.0.60.0000.00816.95
8.0.50.0030.00516.85
8.0.30.0100.00917.24
8.0.20.0060.01217.40
8.0.10.0020.00517.16
8.0.00.0110.00916.94
7.4.330.0020.00216.79
7.4.320.0080.00016.63
7.4.300.0060.00016.42
7.4.290.0030.00516.54
7.4.280.0000.00916.42
7.4.270.0040.00416.53
7.4.260.0090.00316.52
7.4.250.0040.00416.61
7.4.240.0030.00316.54
7.4.230.0040.00416.68
7.4.220.0100.00916.46
7.4.210.0070.00716.63
7.4.200.0030.00316.63
7.4.160.0080.00816.68
7.4.150.0100.00717.40
7.4.140.0150.00617.86
7.4.130.0110.01116.54
7.4.120.0110.01216.58
7.4.110.0070.01016.73
7.4.100.0110.00716.57
7.4.90.0050.01316.61
7.4.80.0100.00719.39
7.4.70.0100.00716.74
7.4.60.0070.01416.58
7.4.50.0000.01816.35
7.4.40.0060.01016.47
7.4.30.0100.01316.66
7.4.00.0030.01015.07
7.3.330.0060.00013.16
7.3.320.0000.00513.25
7.3.310.0000.00716.25
7.3.300.0040.00416.39
7.3.290.0100.00816.38
7.3.280.0080.00916.38
7.3.270.0090.00917.40
7.3.260.0120.01216.44
7.3.250.0050.01316.42
7.3.240.0090.01116.54
7.3.230.0070.01316.63
7.3.210.0120.00616.63
7.3.200.0130.00316.32
7.3.190.0100.00716.58
7.3.180.0060.01216.42
7.3.170.0070.01016.39
7.3.160.0070.01016.43
7.2.330.0100.01316.63
7.2.320.0090.00916.73
7.2.310.0040.01916.63
7.2.300.0090.00616.57
7.2.290.0070.01116.63
7.2.60.0070.00717.10
7.2.00.0030.01219.49
7.1.200.0090.00015.66
7.1.100.0060.00617.60
7.1.70.0000.00816.89
7.1.60.0160.00919.13
7.1.50.0080.00816.88
7.1.00.0000.08022.44
7.0.200.0030.00616.70
7.0.60.0100.08319.92
7.0.50.0230.07017.94
7.0.40.0000.04720.26
7.0.30.0330.07020.21
7.0.20.0270.06320.22
7.0.10.0070.06020.06
7.0.00.0130.08020.07
5.6.280.0000.07021.13
5.6.210.0030.04320.78
5.6.200.0130.05018.14
5.6.190.0000.09720.77
5.6.180.0170.08020.77
5.6.170.0300.07320.47
5.6.160.0070.07020.57
5.6.150.0100.08018.14
5.6.140.0070.08018.28
5.6.130.0100.07718.21
5.6.120.0100.08721.16
5.6.110.0130.03321.16
5.6.100.0070.08021.03
5.6.90.0100.08721.00
5.6.80.0170.06720.39
5.5.350.0170.07020.41
5.5.340.0030.04017.99
5.5.330.0070.08720.40
5.5.320.0330.06720.27
5.5.310.0200.08320.34
5.5.300.0070.08017.98
5.5.290.0070.05017.98
5.5.280.0070.08320.89
5.5.270.0030.09020.81
5.5.260.0000.06320.89
5.5.250.0070.07020.60
5.5.240.0130.04020.09

preferences:
41.85 ms | 401 KiB | 5 Q