3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Singleton { /** * @var Singleton[] The reference to *Singleton* instances of any child class. */ private static $instances = array(); /** * Returns the *Singleton* instance of this class. * * @return static The *Singleton* instance. */ public static function getInstance() { if (!isset(self::$instances[static::class])) { self::$instances[static::class] = new static(); } return self::$instances[static::class]; } /** * 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 { } class AnotherChild extends Singleton { } echo 'Expect: true, true, true, false' . PHP_EOL; var_dump(SingletonChild::getInstance() === SingletonChild::getInstance()); var_dump(AnotherChild::getInstance() === AnotherChild::getInstance()); $a = AnotherChild::getInstance(); var_dump($a === AnotherChild::getInstance()); var_dump($a === SingletonChild::getInstance());

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.5.10.0110.00819.91
8.5.00.0100.01019.94
8.4.150.0010.00114.05
8.4.140.0090.01217.58
8.4.130.0070.01218.72
8.4.120.0120.00924.14
8.4.110.0110.00918.71
8.4.100.0120.00818.76
8.4.90.0130.00620.84
8.4.80.0160.00518.95
8.4.70.0100.00618.99
8.4.60.0130.00619.13
8.4.50.0070.00918.78
8.4.40.0100.01020.49
8.4.30.0160.00317.92
8.4.20.0100.00317.76
8.4.10.0040.00418.00
8.3.280.0120.00818.45
8.3.270.0120.00716.75
8.3.260.0070.00216.85
8.3.250.0100.00918.77
8.3.240.0120.00717.43
8.3.230.0090.00916.94
8.3.220.0110.00818.79
8.3.210.0060.00218.64
8.3.200.0090.00716.59
8.3.190.0110.00817.17
8.3.180.0130.00619.00
8.3.170.0070.01120.74
8.3.160.0120.00617.14
8.3.150.0000.00816.74
8.3.140.0030.00618.53
8.3.130.0040.00818.58
8.3.120.0090.00020.79
8.3.110.0050.00520.94
8.3.100.0000.00824.06
8.3.90.0080.00026.77
8.3.80.0030.00617.97
8.3.70.0090.01218.56
8.3.60.0120.00318.56
8.3.50.0080.01122.77
8.3.40.0090.00618.82
8.3.30.0070.00718.88
8.3.20.0040.00420.16
8.3.10.0020.00521.95
8.3.00.0000.00819.19
8.2.290.0040.00520.68
8.2.280.0120.00720.10
8.2.270.0110.00716.78
8.2.260.0070.00716.97
8.2.250.0000.00818.42
8.2.240.0050.00319.21
8.2.230.0040.00422.58
8.2.220.0000.01037.54
8.2.210.0070.00026.77
8.2.200.0060.00316.75
8.2.190.0040.01816.58
8.2.180.0140.00718.66
8.2.170.0070.00722.96
8.2.160.0150.00019.34
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00920.47
8.2.120.0030.00626.35
8.2.110.0060.00322.27
8.2.100.0110.00018.16
8.2.90.0000.00819.17
8.2.80.0000.00817.97
8.2.70.0080.00017.63
8.2.60.0030.00519.10
8.2.50.0050.00318.10
8.2.40.0040.00420.59
8.2.30.0040.00419.35
8.2.20.0000.00717.66
8.2.10.0050.00218.14
8.2.00.0050.00218.03
8.1.330.0090.00821.88
8.1.320.0120.00917.86
8.1.310.0000.01516.29
8.1.300.0090.00020.31
8.1.290.0100.00030.84
8.1.280.0110.00425.92
8.1.270.0000.00823.84
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00319.46
8.1.230.0110.00017.89
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0000.00917.48
8.1.190.0080.00017.23
8.1.180.0000.00818.10
8.1.170.0050.00318.58
8.1.160.0000.00719.05
8.1.150.0040.00418.97
8.1.140.0040.00419.58
8.1.130.0000.00817.74
8.1.120.0030.00617.50
8.1.110.0030.00717.49
8.1.100.0050.00217.50
8.1.90.0050.00317.55
8.1.80.0000.00717.38
8.1.70.0040.00417.39
8.1.60.0030.00517.59
8.1.50.0080.00017.57
8.1.40.0000.00717.57
8.1.30.0000.01117.55
8.1.20.0000.00817.65
8.1.10.0070.00417.50
8.1.00.0040.00417.55
8.0.300.0000.00718.77
8.0.290.0040.00416.63
8.0.280.0000.00718.49
8.0.270.0030.00317.29
8.0.260.0030.00317.31
8.0.250.0000.00716.93
8.0.240.0000.00717.06
8.0.230.0030.00317.11
8.0.220.0030.00317.05
8.0.210.0000.00816.98
8.0.200.0030.00317.08
8.0.190.0060.00317.07
8.0.180.0040.00417.04
8.0.170.0020.00516.96
8.0.160.0040.00416.95
8.0.150.0080.00016.92
8.0.140.0040.00417.01
8.0.130.0000.00813.37
8.0.120.0050.00316.96
8.0.110.0050.00216.92
8.0.100.0040.00416.86
8.0.90.0080.00016.86
8.0.80.0060.01317.05
8.0.70.0040.00417.02
8.0.60.0000.00817.03
8.0.50.0000.00717.03
8.0.30.0100.00817.06
8.0.20.0090.01017.40
8.0.10.0030.00316.89
8.0.00.0090.00616.75
7.4.330.0030.00315.08
7.4.320.0000.00616.56
7.4.300.0030.00316.61
7.4.290.0000.00716.58
7.4.280.0040.00416.58
7.4.270.0040.00416.55
7.4.260.0030.00516.63
7.4.250.0000.00716.36
7.4.240.0030.00316.52
7.4.230.0070.00016.53
7.4.220.0110.01416.59
7.4.210.0110.00416.41
7.4.200.0030.00316.71
7.4.160.0130.00716.66
7.4.150.0000.01717.40
7.4.140.0180.00317.86
7.4.130.0060.01216.57
7.4.120.0070.01216.54
7.4.110.0100.00716.60
7.4.100.0030.01316.55
7.4.90.0170.00316.59
7.4.80.0130.01019.39
7.4.70.0030.01316.62
7.4.60.0030.01316.56
7.4.50.0070.01116.32
7.4.40.0130.00416.67
7.4.30.0100.00716.70
7.4.10.0060.01314.95
7.4.00.0050.01215.04
7.3.330.0030.00313.32
7.3.320.0000.00513.23
7.3.310.0050.00216.37
7.3.300.0070.00016.23
7.3.290.0080.00816.45
7.3.280.0070.01116.42
7.3.270.0120.00617.40
7.3.260.0110.00616.53
7.3.250.0100.01116.45
7.3.240.0070.01316.59
7.3.230.0150.01116.68
7.3.210.0080.00816.50
7.3.200.0070.01316.40
7.3.190.0060.01016.48
7.3.180.0030.02016.44
7.3.170.0090.01216.47
7.3.160.0090.00616.41
7.3.130.0090.00915.05
7.3.120.0130.00314.62
7.3.110.0130.00614.92
7.3.100.0110.00414.91
7.3.90.0060.01214.94
7.3.80.0100.00714.63
7.3.70.0030.00715.05
7.3.60.0110.00414.75
7.3.50.0060.01214.86
7.3.40.0030.00614.66
7.3.30.0070.00714.69
7.3.20.0000.01416.78
7.3.10.0070.00716.50
7.3.00.0060.00916.88
7.2.330.0070.01116.46
7.2.320.0080.00816.75
7.2.310.0130.00416.91
7.2.300.0090.00916.88
7.2.290.0120.00916.73
7.2.260.0070.01115.24
7.2.250.0070.01014.88
7.2.240.0030.01014.98
7.2.230.0070.00714.96
7.2.220.0040.01114.98
7.2.210.0040.00815.09
7.2.200.0100.00715.12
7.2.190.0070.00315.14
7.2.180.0030.01014.95
7.2.170.0090.00614.88
7.2.160.0030.01314.80
7.2.150.0000.01316.86
7.2.140.0110.00017.00
7.2.130.0040.01116.88
7.2.120.0070.01016.78
7.2.110.0120.00016.93
7.2.100.0000.01516.96
7.2.90.0060.00917.00
7.2.80.0100.00317.11
7.2.70.0100.00316.86
7.2.60.0060.00717.13
7.2.50.0040.01116.95
7.2.40.0130.00317.06
7.2.30.0030.01217.13
7.2.20.0060.00617.02
7.2.10.0000.01417.11
7.2.00.0000.01517.06
7.1.330.0060.00915.79
7.1.320.0120.00615.65
7.1.310.0100.00315.77
7.1.300.0000.00815.83
7.1.290.0000.00815.81
7.1.280.0030.01215.88
7.1.270.0060.00615.85
7.1.260.0080.00315.78
7.1.250.0040.01115.71
7.1.240.0000.01215.63
7.1.230.0000.01115.73
7.1.220.0090.00315.84
7.1.210.0030.00615.73
7.1.200.0050.00815.82
7.1.190.0030.00915.73
7.1.180.0030.01115.87
7.1.170.0000.01315.80
7.1.160.0070.00715.77
7.1.150.0030.01015.90
7.1.140.0030.00615.86
7.1.130.0030.01015.66
7.1.120.0040.01115.92
7.1.110.0000.00915.96
7.1.100.0070.00415.99
7.1.90.0060.00315.80
7.1.80.0120.00415.74
7.1.70.0030.00815.99
7.1.60.0020.01417.75
7.1.50.0080.00315.89
7.1.40.0100.00315.83
7.1.30.0000.01115.82
7.1.20.0000.00815.86
7.1.10.0040.01115.57
7.1.00.0080.03919.16
7.0.330.0030.01315.63
7.0.320.0040.00715.41
7.0.310.0100.00315.20
7.0.300.0140.00015.35
7.0.290.0040.01115.51
7.0.280.0100.00315.20
7.0.270.0060.00915.61
7.0.260.0060.00615.18
7.0.250.0030.00615.39
7.0.240.0070.00715.49
7.0.230.0030.01415.46
7.0.220.0090.00315.42
7.0.210.0060.00315.55
7.0.200.0220.01015.09
7.0.190.0060.00615.28
7.0.180.0030.00915.34
7.0.170.0080.00415.28
7.0.160.0040.01115.63
7.0.150.0000.01215.16
7.0.140.0060.01015.16
7.0.130.0000.01115.36
7.0.120.0060.00915.13
7.0.110.0080.00315.29
7.0.100.0060.01015.33
7.0.90.0030.01315.44
7.0.80.0050.00315.13
7.0.70.0310.02817.72
7.0.60.0270.04017.72
7.0.50.0320.03117.97
7.0.40.0420.03016.94
7.0.30.0320.03316.88
7.0.20.0280.03716.83
7.0.10.0280.03316.80
7.0.00.0320.03016.94
5.6.400.0040.01114.79
5.6.390.0030.01014.79
5.6.380.0000.01014.41
5.6.370.0060.01014.44
5.6.360.0000.01514.34
5.6.350.0030.00614.40
5.6.340.0000.01214.31
5.6.330.0110.00314.27
5.6.320.0030.00614.77
5.6.310.0060.00914.78
5.6.300.0100.00714.46
5.6.290.0060.00314.37
5.6.280.0080.03717.64
5.6.270.0000.01414.63
5.6.260.0090.00914.24
5.6.250.0070.00714.72
5.6.240.0040.00814.49
5.6.230.0070.00714.33
5.6.220.0320.02817.60
5.6.210.0270.03317.66
5.6.200.0300.03217.76
5.6.190.0320.03017.80
5.6.180.0330.02817.83
5.6.170.0250.03717.73
5.6.160.0260.03417.71
5.6.150.0420.03517.68
5.6.140.0300.02917.80
5.6.130.0250.03417.76
5.6.120.0210.03417.82
5.6.110.0280.03517.71
5.6.100.0320.03517.74
5.6.90.0340.03617.68
5.6.80.0280.03417.39
5.6.70.0340.02617.44
5.6.60.0310.03017.26
5.6.50.0250.04017.46
5.6.40.0230.03217.30
5.6.30.0320.02717.52
5.6.20.0250.03317.45
5.6.10.0410.03417.39
5.6.00.0360.02617.44
5.5.380.0040.00714.21
5.5.370.0100.00714.45
5.5.360.0320.03317.63
5.5.350.0280.03217.54
5.5.340.0250.03517.72
5.5.330.0230.03617.55
5.5.320.0330.02717.68
5.5.310.0300.03317.77
5.5.300.0290.03417.69
5.5.290.0280.03517.66
5.5.280.0070.03417.60
5.5.270.0300.03017.75
5.5.260.0280.03517.73
5.5.250.0250.03417.55
5.5.240.0280.03317.24
5.5.230.0290.03917.36
5.5.220.0280.03317.22
5.5.210.0300.02717.28
5.5.200.0260.03317.38
5.5.190.0310.02817.24
5.5.180.0300.02817.35
5.5.170.0050.00514.48
5.5.160.0290.02917.25
5.5.150.0320.02717.29
5.5.140.0250.03017.35
5.5.130.0330.02817.33
5.5.120.0230.03517.25
5.5.110.0330.02817.34
5.5.100.0160.03117.14
5.5.90.0250.03117.09
5.5.80.0270.03217.35
5.5.70.0270.04217.24
5.5.60.0290.03917.28
5.5.50.0170.04117.32
5.5.40.1550.02817.14
5.5.30.0220.03017.09
5.5.20.0230.03817.22
5.5.10.0220.03417.34
5.5.00.0160.03316.97
5.4.450.0430.06019.41
5.4.440.0100.05719.41
5.4.430.0500.06719.52
5.4.420.0570.05319.46
5.4.410.0530.05719.35
5.4.400.0430.06319.16
5.4.390.0500.06019.17
5.4.380.0470.05319.04
5.4.370.0630.05718.90
5.4.360.0500.06019.17
5.4.350.0500.05319.10
5.4.340.0470.05319.10
5.4.320.0570.04719.19
5.4.310.0570.05019.27
5.4.300.0600.04319.04
5.4.290.0500.06719.17
5.4.280.0530.06719.09
5.4.270.0370.05719.14
5.4.260.0430.05019.15
5.4.250.0170.05019.13
5.4.240.0470.07719.15
5.4.230.0600.07019.24
5.4.220.0670.07019.03
5.4.210.0400.05019.15
5.4.200.1370.04719.09
5.4.190.0330.06318.89
5.4.180.0330.05719.13
5.4.170.0500.04718.92
5.4.160.0370.04719.17
5.4.150.0300.06019.17
5.4.140.0370.05316.60
5.4.130.0530.02716.45
5.4.120.0230.05316.39
5.4.110.0300.05716.62
5.4.100.0370.05016.47
5.4.90.0400.04016.51
5.4.80.0330.05016.61
5.4.70.0370.04316.62
5.4.60.0300.05716.54
5.4.50.0400.05016.43
5.4.40.0200.05316.63
5.4.30.0370.06716.54
5.4.20.0170.04716.51
5.4.10.0230.04716.53
5.4.00.0130.05315.78
5.3.290.0430.05314.66
5.3.280.0330.07314.59
5.3.270.0270.06014.60
5.3.260.0400.07014.61
5.3.250.0470.04714.61
5.3.240.0330.05014.64
5.3.230.0230.05714.56
5.3.220.0230.06014.57
5.3.210.0330.06014.57
5.3.200.0400.04714.59
5.3.190.0270.05714.69
5.3.180.0470.06314.70
5.3.170.0330.05014.58
5.3.160.0330.05314.53
5.3.150.0330.07014.54
5.3.140.0130.06014.57
5.3.130.0170.05014.52
5.3.120.0230.04314.69
5.3.110.0100.05714.66
5.3.100.0200.06014.04
5.3.90.0300.06014.13
5.3.80.0200.04714.02
5.3.70.0130.05314.05
5.3.60.0130.05013.97
5.3.50.0130.07014.05
5.3.40.0130.05313.89
5.3.30.0130.06013.85
5.3.20.0200.04313.83
5.3.10.0170.04713.77
5.3.00.0130.05013.66
5.2.170.0170.04011.07
5.2.160.0030.05011.14
5.2.150.0070.06310.98
5.2.140.0030.05011.28
5.2.130.0130.05311.10
5.2.120.0270.03711.08
5.2.110.0170.03311.09
5.2.100.0170.03311.21
5.2.90.0170.04011.02
5.2.80.0100.04011.12
5.2.70.0530.04711.08
5.2.60.0070.04711.07
5.2.50.0200.04310.94
5.2.40.0100.04711.03
5.2.30.0200.04010.96
5.2.20.0130.05310.96
5.2.10.0300.03310.89
5.2.00.0600.04010.75
5.1.60.0230.0439.98
5.1.50.0100.0409.96
5.1.40.0100.0409.97
5.1.30.0600.03010.37
5.1.20.0330.04710.46
5.1.10.0170.05310.11
5.1.00.0100.03310.15
5.0.50.0000.0378.49
5.0.40.0100.0238.44
5.0.30.0430.0408.22
5.0.20.0070.0278.29
5.0.10.0400.0278.15
5.0.00.0400.0408.11
4.4.90.0130.0135.87
4.4.80.0100.0205.87
4.4.70.0030.0275.87
4.4.60.0100.0205.87
4.4.50.0430.0275.87
4.4.40.0100.0375.87
4.4.30.0130.0235.87
4.4.20.0200.0305.87
4.4.10.0100.0175.87
4.4.00.0100.0305.87
4.3.110.0030.0235.87
4.3.100.0100.0205.87
4.3.90.0070.0205.87
4.3.80.0000.0375.87
4.3.70.0070.0235.87
4.3.60.0100.0275.87
4.3.50.0100.0275.87
4.3.40.0000.0435.87
4.3.30.0000.0275.87
4.3.20.0000.0275.87
4.3.10.0070.0175.87
4.3.00.0030.0205.87

preferences:
205.99 ms | 403 KiB | 5 Q