3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { private static $instanciated = false; public function __construct() { if (self::$instanciated === true) { throw new RuntimeException('Could not instanciate class'); } self::$instanciated = true; echo "new instance\n"; } private $var; public function get(): int { return $this->var; } public function set(int $value) { $this->var = $value; } } class Factory { private $instance = null; public function getInstance() { echo "getInstance()\n"; if ($this->instance === null) { $this->instance = new Singleton(); } return $this->instance; } } $factory = new Factory(); $o = $factory->getInstance(); $o->set(5); $factory2 = new Factory(); try { $o2 = $factory->getInstance(); var_dump($o2->get()); } catch (Throwable $e) { echo "Non: ", $e->getMessage(), "\n"; }

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.63
8.3.50.0120.01622.11
8.3.40.0070.01318.79
8.3.30.0030.01018.86
8.3.20.0080.00020.29
8.3.10.0000.00821.77
8.3.00.0000.00819.50
8.2.180.0150.00618.54
8.2.170.0000.01422.96
8.2.160.0100.00320.38
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0090.00017.50
8.2.110.0040.00822.25
8.2.100.0080.00417.93
8.2.90.0050.00319.22
8.2.80.0000.00817.97
8.2.70.0000.00817.75
8.2.60.0000.00818.03
8.2.50.0090.00018.07
8.2.40.0030.00519.23
8.2.30.0000.00720.53
8.2.20.0040.00417.54
8.2.10.0040.00418.03
8.2.00.0050.00318.13
8.1.280.0070.01425.92
8.1.270.0050.00323.81
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00620.76
8.1.230.0070.00717.65
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0050.00517.22
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0030.00718.88
8.1.160.0000.00821.96
8.1.150.0060.00318.75
8.1.140.0030.00519.58
8.1.130.0070.00017.57
8.1.120.0040.00417.45
8.1.110.0000.00717.38
8.1.100.0030.00617.45
8.1.90.0050.00217.39
8.1.80.0080.00317.29
8.1.70.0030.00317.37
8.1.60.0000.00817.64
8.1.50.0000.00817.50
8.1.40.0060.00317.49
8.1.30.0000.00817.67
8.1.20.0030.00517.64
8.1.10.0040.00417.57
8.1.00.0080.00017.51
8.0.300.0040.00418.77
8.0.290.0040.00416.63
8.0.280.0040.00418.48
8.0.270.0000.00717.19
8.0.260.0030.00317.18
8.0.250.0070.00016.79
8.0.240.0040.00416.79
8.0.230.0060.00316.93
8.0.220.0070.00016.83
8.0.210.0080.00016.79
8.0.200.0000.00716.88
8.0.190.0110.00016.81
8.0.180.0080.00016.75
8.0.170.0070.00016.84
8.0.160.0030.00416.79
8.0.150.0030.00316.79
8.0.140.0000.00716.81
8.0.130.0030.00313.30
8.0.120.0080.00016.82
8.0.110.0000.00716.84
8.0.100.0040.00416.73
8.0.90.0050.00216.70
8.0.80.0090.00616.85
8.0.70.0020.00516.70
8.0.60.0050.00216.67
8.0.50.0000.00716.71
8.0.30.0130.00817.05
8.0.20.0090.01117.40
8.0.10.0050.00316.84
8.0.00.0100.01016.73
7.4.330.0020.00215.08
7.4.320.0060.00016.61
7.4.300.0030.00316.59
7.4.290.0040.00416.57
7.4.280.0070.00016.49
7.4.270.0030.00316.51
7.4.260.0000.00716.54
7.4.250.0040.00416.48
7.4.240.0000.00716.51
7.4.230.0070.00016.69
7.4.220.0100.00716.69
7.4.210.0080.00816.70
7.4.200.0070.00016.40
7.4.160.0120.00416.59
7.4.150.0070.01017.40
7.4.140.0150.01117.86
7.4.130.0170.00616.52
7.4.120.0130.00816.69
7.4.110.0220.00016.50
7.4.100.0100.00716.59
7.4.90.0130.00816.46
7.4.80.0090.00919.39
7.4.70.0090.01416.61
7.4.60.0090.00616.46
7.4.50.0030.00316.56
7.4.40.0000.01616.37
7.4.30.0090.00916.52
7.4.00.0060.01015.10
7.3.330.0020.00213.18
7.3.320.0060.00013.30
7.3.310.0030.00516.36
7.3.300.0000.00716.18
7.3.290.0030.00316.23
7.3.280.0090.00816.30
7.3.270.0040.01417.40
7.3.260.0100.00716.39
7.3.240.0080.01216.35
7.3.230.0030.01316.39
7.3.210.0110.00716.54
7.3.200.0100.00616.23
7.3.190.0130.00316.57
7.3.180.0070.01416.49
7.3.170.0120.00616.39
7.3.160.0100.01016.38
7.2.330.0140.00316.77
7.2.320.0120.01216.72
7.2.310.0110.00716.80
7.2.300.0040.01416.57
7.2.290.0030.01916.81
7.2.60.0040.01116.71
7.2.00.0070.00719.47
7.1.200.0030.00915.75
7.1.100.0070.00718.23
7.1.70.0030.01217.14
7.1.60.0100.01319.43
7.1.50.0090.00916.98
7.1.00.0070.07322.40
7.0.200.0350.00014.51
7.0.60.0000.07020.04
7.0.50.0100.07018.00
7.0.40.0100.03720.40
7.0.30.0400.05720.27
7.0.20.0400.07020.09
7.0.10.0100.08320.16
7.0.00.0130.07720.22
5.6.280.0070.06320.93
5.6.210.0000.04020.55
5.6.200.0100.07318.12
5.6.190.0030.09720.46
5.6.180.0330.07020.39
5.6.170.0300.07320.71
5.6.160.0070.09320.52
5.6.150.0070.07018.22
5.6.140.0030.07018.15
5.6.130.0030.08318.18
5.6.120.0170.08021.00
5.6.110.0130.07720.98
5.6.100.0100.08021.11
5.6.90.0070.05721.13
5.6.80.0100.07320.52
5.5.350.0370.07320.31
5.5.340.0070.06017.99
5.5.330.0130.03720.40
5.5.320.0200.04720.31
5.5.310.0170.03720.26
5.5.300.0000.04318.04
5.5.290.0030.04317.97
5.5.280.0100.04320.80
5.5.270.0000.04320.77
5.5.260.0070.04020.77
5.5.250.0100.08020.47
5.5.240.0100.06020.05
5.4.450.0200.05319.34
5.4.440.0170.05719.34
5.4.430.0270.04719.54
5.4.420.0100.06019.28
5.4.410.0170.05319.28
5.4.400.0030.06318.96
5.4.390.0100.06019.20
5.4.380.0130.05318.96
5.4.370.0230.04319.04
5.4.360.0100.06019.02
5.4.350.0170.05319.07
5.4.340.0100.06019.18
5.4.320.0200.05319.07
5.4.310.0100.05719.32
5.4.300.0170.05019.20
5.4.290.0170.05719.18
5.4.280.0230.04719.01
5.4.270.0300.05019.06
5.4.260.0170.05319.20
5.4.250.0230.04719.32
5.4.240.0200.04719.03
5.4.230.0300.06019.32
5.4.220.0170.07319.02
5.4.210.0200.04719.20
5.4.200.0200.04718.95
5.4.190.0100.05718.78
5.4.180.0370.03318.79
5.4.170.0170.05019.03
5.4.160.0170.05019.19
5.4.150.0230.06019.20
5.4.140.0070.05716.32
5.4.130.0170.04716.40
5.4.120.0130.05716.58
5.4.110.0170.07016.18
5.4.100.0130.06716.57
5.4.90.0170.04716.27
5.4.80.0130.06016.45
5.4.70.0270.06016.49
5.4.60.0100.05316.49
5.4.50.0230.04716.49
5.4.40.0170.05016.53
5.4.30.0100.05316.24
5.4.20.0130.05016.24
5.4.10.0170.05016.48
5.4.00.0200.04316.16

preferences:
66.69 ms | 401 KiB | 5 Q