3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { /** * @var Singleton The reference to *Singleton* instance of this class */ protected static $instance; /** * Returns the *Singleton* instance of this class. * * @return Singleton The *Singleton* instance. */ public static function getInstance() { if (null === static::$instance) { static::$instance = new static(); } return static::$instance; } /** * Protected constructor to prevent creating a new instance of the * *Singleton* via the `new` operator from outside of this class. */ protected function __construct() { } /** * Private clone method to prevent cloning of the instance of the * *Singleton* instance. * * @return void */ private function __clone() { } /** * Private unserialize method to prevent unserializing of the *Singleton* * instance. * * @return void */ private function __wakeup() { } } class SingletonChild extends Singleton { } $obj = Singleton::getInstance(); var_dump($obj === Singleton::getInstance()); // bool(true) $anotherObj = SingletonChild::getInstance(); var_dump($anotherObj === Singleton::getInstance()); // bool(false) var_dump($anotherObj === SingletonChild::getInstance()); // bool(true)

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.01218.43
8.3.50.0110.00716.59
8.3.40.0120.00318.76
8.3.30.0110.00319.07
8.3.20.0080.00020.09
8.3.10.0060.00321.80
8.3.00.0040.00419.07
8.2.180.0100.01016.88
8.2.170.0040.01122.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0140.00026.16
8.2.120.0040.00421.04
8.2.110.0000.01121.18
8.2.100.0040.00717.84
8.2.90.0040.00418.03
8.2.80.0040.00418.22
8.2.70.0080.00017.63
8.2.60.0060.00317.50
8.2.50.0080.00017.50
8.2.40.0030.00519.36
8.2.30.0000.00717.89
8.2.20.0040.00417.62
8.2.10.0050.00317.95
8.2.00.0070.00018.01
8.1.280.0100.00725.92
8.1.270.0070.00020.38
8.1.260.0130.00626.35
8.1.250.0080.00828.09
8.1.240.0090.00024.02
8.1.230.0100.00322.67
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0080.00017.22
8.1.190.0030.00517.23
8.1.180.0040.00418.10
8.1.170.0040.00417.62
8.1.160.0000.00721.97
8.1.150.0030.00618.76
8.1.140.0000.00717.34
8.1.130.0000.00717.91
8.1.120.0040.00417.39
8.1.110.0000.00717.43
8.1.100.0000.00717.42
8.1.90.0070.00017.32
8.1.80.0040.00717.41
8.1.70.0000.00717.42
8.1.60.0060.00317.58
8.1.50.0000.00817.57
8.1.40.0030.00617.57
8.1.30.0050.00317.49
8.1.20.0000.00817.52
8.1.10.0060.00317.54
8.1.00.0030.00517.51
8.0.300.0030.00619.86
8.0.290.0000.00716.63
8.0.280.0000.00718.40
8.0.270.0070.00017.20
8.0.260.0000.00818.40
8.0.250.0000.00717.04
8.0.240.0000.00816.91
8.0.230.0000.00716.98
8.0.220.0000.00716.92
8.0.210.0030.00316.93
8.0.200.0070.00017.01
8.0.190.0040.00416.86
8.0.180.0070.00016.84
8.0.170.0040.00416.91
8.0.160.0040.00416.82
8.0.150.0040.00416.84
8.0.140.0030.00916.77
8.0.130.0000.01113.28
8.0.120.0050.00316.71
8.0.110.0040.00416.76
8.0.100.0030.00516.89
8.0.90.0040.00416.77
8.0.80.0120.00316.93
8.0.70.0000.00716.89
8.0.60.0080.00016.89
8.0.50.0000.00716.86
8.0.30.0110.00617.00
8.0.20.0080.01317.40
8.0.10.0030.00516.84
8.0.00.0090.01116.92
7.4.330.0030.00315.03
7.4.320.0030.00316.47
7.4.300.0040.00416.65
7.4.290.0030.00316.54
7.4.280.0060.00316.62
7.4.270.0040.00416.66
7.4.260.0050.00316.57
7.4.250.0050.00316.55
7.4.240.0040.00316.54
7.4.230.0000.00716.71
7.4.220.0130.01516.36
7.4.210.0110.00316.59
7.4.200.0000.00716.63
7.4.160.0120.00316.52
7.4.150.0120.00617.40
7.4.140.0100.01317.86
7.4.130.0130.01616.40
7.4.120.0100.00716.49
7.4.110.0130.01016.66
7.4.100.0110.01116.54
7.4.90.0130.00316.39
7.4.80.0050.01119.39
7.4.70.0090.00916.41
7.4.60.0100.00716.40
7.4.50.0000.00616.64
7.4.40.0060.01216.26
7.4.30.0040.01816.59
7.4.00.0100.00714.69
7.3.330.0000.00513.22
7.3.320.0050.00013.40
7.3.310.0030.00316.39
7.3.300.0070.00016.25
7.3.290.0070.00616.37
7.3.280.0120.00516.39
7.3.270.0090.00917.40
7.3.260.0100.00716.30
7.3.240.0060.01116.51
7.3.230.0140.00916.59
7.3.210.0100.00716.37
7.3.200.0160.00619.39
7.3.190.0110.00416.36
7.3.180.0070.01016.54
7.3.170.0040.01316.38
7.3.160.0060.00916.55
7.3.10.0060.00616.38
7.3.00.0070.01316.20
7.2.330.0060.01516.62
7.2.320.0110.00616.21
7.2.310.0030.01316.66
7.2.300.0170.00016.67
7.2.290.0100.01316.62
7.2.130.0000.01416.65
7.2.120.0120.00316.25
7.2.110.0340.00216.54
7.2.100.0140.00416.68
7.2.90.0070.01016.38
7.2.80.0160.00316.64
7.2.70.0070.01116.32
7.2.60.0050.01216.71
7.2.50.0180.00716.61
7.2.40.0110.00716.77
7.2.30.0190.00216.74
7.2.20.0050.01016.19
7.2.10.0140.00716.44
7.2.00.0040.01217.98
7.1.250.0160.00015.24
7.1.200.0050.00515.89
7.1.100.0000.00818.36
7.1.70.0040.00416.93
7.1.60.0100.01419.59
7.1.50.0030.01416.94
7.1.00.0030.07722.36
7.0.200.0120.01216.70
7.0.100.0100.07019.99
7.0.90.0100.07319.88
7.0.80.0130.03319.92
7.0.70.0000.04719.89
7.0.60.0070.04019.93
7.0.50.0130.07020.25
7.0.40.0070.08020.05
7.0.30.0070.06320.00
7.0.20.0130.06020.14
7.0.10.0070.03719.99
7.0.00.0030.05020.04
5.6.280.0100.06721.03
5.6.250.0070.07720.68
5.6.240.0070.08720.46
5.6.230.0000.04720.64
5.6.220.0130.03320.66
5.6.210.0000.04320.56
5.6.200.0030.04021.04
5.6.190.0070.07721.05
5.6.180.0030.08020.99
5.6.170.0000.04320.91
5.6.160.0070.04320.96
5.6.150.0070.03720.95
5.6.140.0000.04721.02
5.6.130.0030.04321.13
5.6.120.0000.04721.00
5.6.110.0030.04321.03
5.6.100.0070.07020.99
5.6.90.0070.07721.01
5.6.80.0070.08320.48
5.6.70.0130.02720.40
5.6.60.0030.05020.39
5.6.50.0000.04720.35
5.6.40.0000.04320.41
5.6.30.0030.04020.32
5.6.20.0030.04020.33
5.6.10.0100.06720.41
5.6.00.0000.05320.47
5.5.380.0100.07720.47
5.5.370.0030.05020.35
5.5.360.0030.04320.46
5.5.350.0070.04020.40
5.5.340.0130.08020.89
5.5.330.0100.08020.69
5.5.320.0070.04020.80
5.5.310.0000.04320.71
5.5.300.0000.04320.79
5.5.290.0030.04320.84
5.5.280.0070.04020.84
5.5.270.0030.04020.86
5.5.260.0070.04020.84
5.5.250.0000.04020.64
5.5.240.0100.03320.26
5.5.230.0070.07719.97
5.5.220.0030.04720.16
5.5.210.0030.04020.17
5.5.200.0030.04020.02
5.5.190.0100.03319.99
5.5.180.0000.04320.18
5.5.160.0100.05320.14
5.5.150.0030.04020.18
5.5.140.0100.03320.07
5.5.130.0030.08020.23
5.5.120.0070.08019.93
5.5.110.0170.07320.08
5.5.100.0100.07720.03
5.5.90.0100.07320.02
5.5.80.0030.08320.13
5.5.70.0030.08320.03
5.5.60.0070.05320.07
5.5.50.0230.05319.88
5.5.40.0130.05720.04
5.5.30.0030.08019.88
5.5.20.0100.07320.08
5.5.10.0070.07319.95
5.5.00.0100.07319.92
5.4.450.0100.03319.20
5.4.440.0030.04019.46
5.4.430.0000.04319.36
5.4.420.0000.04719.20
5.4.410.0100.03319.04
5.4.400.0030.03719.09
5.4.390.0070.04319.04
5.4.380.0070.06318.85
5.4.370.0000.04019.23
5.4.360.0030.03719.19
5.4.350.0030.04319.09
5.4.340.0070.03319.05
5.4.320.0100.03319.18
5.4.310.0070.03719.04
5.4.300.0030.04319.04
5.4.290.0130.07019.21
5.4.280.0070.04019.20
5.4.270.0100.07019.22
5.4.260.0000.07718.89
5.4.250.0070.07719.03
5.4.240.0070.07319.10
5.4.230.0100.06718.84
5.4.220.0130.07018.87
5.4.210.0070.04319.12
5.4.200.0030.04019.16
5.4.190.0100.06319.03
5.4.180.0100.05319.03
5.4.170.0100.08019.18
5.4.160.0030.08019.11
5.4.150.0000.08019.19
5.4.140.0070.07016.24
5.4.130.0200.05716.41
5.4.120.0070.07316.42
5.4.110.0070.07316.56
5.4.100.0070.07016.45
5.4.90.0100.06716.45
5.4.80.0200.05316.47
5.4.70.0070.07316.48
5.4.60.0130.04716.31
5.4.50.0130.05316.45
5.4.40.0030.05316.36
5.4.30.0070.06016.48
5.4.20.0070.06316.36
5.4.10.0100.04016.33
5.4.00.0100.06715.81
5.3.290.0000.04714.74
5.3.280.0070.07714.74
5.3.270.0030.08314.60
5.3.260.0000.05014.74
5.3.250.0100.07314.54
5.3.240.0100.06014.60
5.3.230.0200.03014.63
5.3.220.0070.05314.55
5.3.210.0070.07014.66
5.3.200.0030.08014.59
5.3.190.0070.07314.63
5.3.180.0070.07714.54
5.3.170.0030.04314.62
5.3.160.0130.06714.70
5.3.150.0130.07314.70
5.3.140.0070.07314.63
5.3.130.0070.08014.45
5.3.120.0100.07014.54
5.3.110.0100.07014.53
5.3.100.0070.06714.02
5.3.90.0100.07314.09
5.3.80.0170.06313.95
5.3.70.0030.06714.09
5.3.60.0070.07314.09
5.3.50.0000.04713.89
5.3.40.0100.07014.02
5.3.30.0030.05314.02
5.3.20.0130.06713.84
5.3.10.0070.06713.72
5.3.00.0070.07013.75
5.2.170.0070.06012.43
5.2.160.0030.06312.43
5.2.150.0070.04712.43
5.2.140.0030.06312.43
5.2.130.0030.06012.43
5.2.120.0070.04712.43
5.2.110.0070.06012.43
5.2.100.0070.05712.43
5.2.90.0100.05312.43
5.2.80.0070.05312.43
5.2.70.0100.05712.43
5.2.60.0130.05312.43
5.2.50.0030.06012.43
5.2.40.0030.05712.43
5.2.30.0070.05712.43
5.2.20.0070.05712.43
5.2.10.0130.05712.43
5.2.00.0070.05712.43
5.1.60.0070.04712.43
5.1.50.0000.05712.43
5.1.40.0000.03312.43
5.1.30.0070.05312.43
5.1.20.0070.05312.43
5.1.10.0030.05712.43
5.1.00.0070.05312.43
5.0.50.0000.02712.43
5.0.40.0070.04012.43
5.0.30.0030.06312.43
5.0.20.0030.04712.43
5.0.10.0070.04312.43
5.0.00.0030.06312.43
4.4.90.0030.03712.43
4.4.80.0030.02712.43
4.4.70.0030.03712.43
4.4.60.0030.03312.43
4.4.50.0070.02712.43
4.4.40.0030.02712.43
4.4.30.0070.03012.43
4.4.20.0000.03712.43
4.4.10.0000.03712.43
4.4.00.0000.05012.43
4.3.110.0000.03712.43
4.3.100.0000.04012.43
4.3.90.0030.03312.43
4.3.80.0000.05712.43
4.3.70.0030.02312.43
4.3.60.0030.03712.43
4.3.50.0130.02312.43
4.3.40.0030.02712.43
4.3.30.0030.02312.43
4.3.20.0000.02712.43
4.3.10.0070.01312.43
4.3.00.0000.01712.43

preferences:
59.56 ms | 400 KiB | 5 Q