3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity { private $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; return $this; } } class DB { public function findByName($name) { if ($name === 'belette') { return new Entity($name); } return false; } } class Test { private $db; public function __construct(DB $db) { $this->db = $db; } public function getEntity($name): Entity { $entity = $this->db->findByName($name); $new = false; if (false === $entity) { $entity = new Entity(); $entity->setName($name); $this->db->insert($entity); $new = true; } return new class($entity, $new) { private $new; public $entity; public function __construct(Entity $entity, $new) { $this->entity = $entity; $this->new = $new; } public function isNew() { return $this->new; } }; } } $db = new DB(); $test = new Test($db); $result = $test->getEntity('belette'); if ($result->isNew()) { echo "L'entité 'belette' n'existait pas en base\n"; } var_dump($result->entity);

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.0110.01116.88
8.3.50.0110.00418.05
8.3.40.0090.00618.96
8.3.30.0070.00718.98
8.3.20.0040.00420.18
8.3.10.0090.00023.57
8.3.00.0000.00819.51
8.2.180.0070.01418.54
8.2.170.0080.00822.96
8.2.160.0130.00322.19
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0060.00317.50
8.2.120.0000.00826.35
8.2.110.0060.00322.08
8.2.100.0150.00017.80
8.2.90.0000.00819.28
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0030.00617.90
8.2.50.0060.00318.07
8.2.40.0030.00619.46
8.2.30.0040.00420.53
8.2.20.0090.00017.75
8.2.10.0030.00518.03
8.2.00.0000.00718.02
8.1.280.0070.01125.92
8.1.270.0030.00622.20
8.1.260.0030.00328.09
8.1.250.0030.00528.09
8.1.240.0030.00722.66
8.1.230.0070.00417.76
8.1.220.0000.00917.79
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0030.00617.35
8.1.180.0060.00318.10
8.1.170.0080.00018.78
8.1.160.0030.00522.11
8.1.150.0070.00018.93
8.1.140.0030.00519.63
8.1.130.0050.00517.80
8.1.120.0080.00017.49
8.1.110.0030.00717.48
8.1.100.0040.00417.38
8.1.90.0030.00517.49
8.1.80.0030.00517.43
8.1.70.0050.00317.44
8.1.60.0000.00917.57
8.1.50.0080.00017.48
8.1.40.0040.00417.55
8.1.30.0000.01017.70
8.1.20.0040.00717.64
8.1.10.0000.00817.59
8.1.00.0000.00817.51
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0080.00018.41
8.0.270.0040.00417.29
8.0.260.0030.00317.29
8.0.250.0000.01017.10
8.0.240.0030.00617.07
8.0.230.0040.00417.04
8.0.220.0080.00016.92
8.0.210.0040.00416.96
8.0.200.0030.00316.93
8.0.190.0060.00316.95
8.0.180.0040.00416.97
8.0.170.0030.00516.99
8.0.160.0070.00016.90
8.0.150.0040.00416.96
8.0.140.0040.00416.96
8.0.130.0000.00613.41
8.0.120.0030.00616.96
8.0.110.0040.00416.88
8.0.100.0050.00316.93
8.0.90.0040.00416.96
8.0.80.0110.00416.99
8.0.70.0030.00617.02
8.0.60.0080.00016.99
8.0.50.0040.00416.85
8.0.30.0080.01117.22
8.0.20.0100.01117.41
8.0.10.0080.00016.98
8.0.00.0090.01016.83
7.4.330.0050.00016.88
7.4.320.0030.00316.55
7.4.300.0000.00816.45
7.4.290.0030.00316.62
7.4.280.0040.00416.51
7.4.270.0000.00716.56
7.4.260.0000.00816.62
7.4.250.0080.00016.61
7.4.240.0020.00516.64
7.4.230.0040.00416.65
7.4.220.0190.00016.48
7.4.210.0040.01316.50
7.4.200.0040.00316.52
7.4.160.0030.01216.54
7.4.150.0060.01217.40
7.4.140.0100.00917.86
7.4.130.0150.00516.36
7.4.120.0050.01216.66
7.4.110.0170.00616.42
7.4.100.0130.01016.45
7.4.90.0030.01416.72
7.4.80.0120.00619.39
7.4.70.0070.01016.62
7.4.60.0000.01716.55
7.4.50.0030.01216.80
7.4.40.0150.00316.54
7.4.30.0100.01016.77
7.4.00.0000.01715.23
7.3.330.0000.00513.45
7.3.320.0030.00313.50
7.3.310.0070.00016.45
7.3.300.0000.00716.32
7.3.290.0070.00016.37
7.3.280.0070.00916.45
7.3.270.0190.00717.40
7.3.260.0110.00716.69
7.3.240.0090.01116.48
7.3.230.0160.00016.39
7.3.210.0070.01016.45
7.3.200.0100.01316.50
7.3.190.0030.01416.38
7.3.180.0070.01416.43
7.3.170.0090.01216.37
7.3.160.0090.00616.53
7.3.120.0100.00714.88
7.3.110.0000.01715.06
7.3.100.0100.00314.95
7.3.90.0100.00314.98
7.3.80.0100.00715.04
7.3.70.0070.01414.97
7.3.60.0040.01815.02
7.3.50.0080.00814.79
7.3.40.0040.00814.96
7.3.30.0030.00614.86
7.3.20.0080.00816.65
7.3.10.0100.00716.67
7.3.00.0060.00916.76
7.2.330.0060.01316.59
7.2.320.0100.00716.68
7.2.310.0030.01316.93
7.2.300.0060.01316.90
7.2.290.0120.00616.88
7.2.240.0100.00715.06
7.2.230.0080.00415.18
7.2.220.0030.01014.96
7.2.210.0120.00015.26
7.2.200.0060.00914.89
7.2.190.0070.01414.74
7.2.180.0070.01014.96
7.2.170.0030.00915.25
7.2.160.0110.00414.91
7.2.150.0030.01317.00
7.2.140.0060.00616.95
7.2.130.0140.00317.03
7.2.120.0150.00716.81
7.2.110.0070.01016.90
7.2.100.0040.01216.73
7.2.90.0100.00716.91
7.2.80.0090.01217.17
7.2.70.0090.00916.85
7.2.60.0200.00616.82
7.2.50.0080.00817.11
7.2.40.0000.01416.66
7.2.30.0100.00317.02
7.2.20.0120.00316.70
7.2.10.0070.00616.65
7.2.00.0130.00717.72
7.1.330.0080.00815.70
7.1.320.0160.00015.70
7.1.310.0160.00415.73
7.1.300.0140.00415.70
7.1.290.0090.00615.67
7.1.280.0040.00715.88
7.1.270.0130.00715.43
7.1.260.0090.00615.76
7.1.250.0070.01115.55
7.1.200.0030.01015.61
7.1.100.0030.01017.90
7.1.70.0040.00417.19
7.1.60.0040.02119.48
7.1.50.0050.00516.99
7.1.00.0000.08022.31
7.0.200.0360.00014.80
7.0.60.0170.04319.96
7.0.50.0130.06717.81
7.0.40.0000.05320.11
7.0.30.0300.05320.33
7.0.20.0400.06020.30
7.0.10.0100.08320.33
7.0.00.0070.04020.32
5.6.210.0100.06320.68
5.6.200.0030.09018.22
5.6.190.0070.04020.64
5.6.180.0570.06320.61
5.6.170.0330.04720.47
5.6.160.0000.04720.48
5.6.150.0070.09018.18
5.6.140.0100.07018.16
5.6.130.0000.05318.18
5.6.120.0030.05321.11
5.6.110.0270.05320.99
5.6.100.0100.03721.14
5.6.90.0100.07321.04
5.6.80.0100.07720.43
5.5.350.0230.03720.45
5.5.340.0070.06017.95
5.5.330.0200.08020.26
5.5.320.0370.04320.36
5.5.310.0200.04320.35
5.5.300.0030.07717.95
5.5.290.0130.07717.95
5.5.280.0070.03720.91
5.5.270.0130.04720.86
5.5.260.0100.06720.90
5.5.250.0030.06720.70
5.5.240.0200.07720.20

preferences:
46.11 ms | 400 KiB | 5 Q