3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$in2 = Closure::bind(function () {$this->ruler = 'jesus';}, $inst, get_class($inst)); class Singleton { protected static $instance; // object instance private function __construct(){ /* ... @return Singleton */ } // Защищаем от создания через new Singleton private function __clone() { /* ... @return Singleton */ } // Защищаем от создания через клонирование private function __wakeup() { /* ... @return Singleton */ } // Защищаем от создания через unserialize public static function getInstance() { // Возвращает единственный экземпляр класса. @return Singleton if ( !isset(self::$instance) ) { $class = __CLASS__; self::$instance = new $class(); self::$instance->id = mt_rand(1,1000); } return self::$instance; } public function doAction() { echo $this->id; } } $singy = Singleton::getInstance(); $singy->doAction(); $singy2 = Singleton::getInstance(); var_dump($singy, $singy2); $derp = Closure::bind(function () {$fake = new Singleton(); $fake->id='hacked'; return $fake;}, $singy2, get_class($singy2)); $singy2 = $derp(); $singy2->doAction(); $singy->doAction(); var_dump($singy, $singy2);

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)
7.4.00.0070.00614.85
7.3.120.0100.00715.10
7.3.110.0090.00614.82
7.3.100.0000.01414.84
7.3.90.0030.01014.81
7.3.80.0120.00314.87
7.3.70.0060.00914.91
7.3.60.0070.00714.89
7.3.50.0070.00714.96
7.3.40.0080.00414.97
7.3.30.0000.01314.97
7.3.20.0030.00616.76
7.3.10.0000.01016.43
7.3.00.0040.01116.88
7.2.250.0070.00715.03
7.2.240.0000.01115.27
7.2.230.0070.00714.91
7.2.220.0060.00814.91
7.2.210.0060.01014.87
7.2.200.0120.00314.91
7.2.190.0090.00614.96
7.2.180.0090.00614.86
7.2.170.0080.00315.16
7.2.00.0000.01119.32
7.1.330.0030.01315.86
7.1.320.0070.01015.93
7.1.310.0080.00315.71
7.1.300.0000.00915.57
7.1.290.0070.00715.77
7.1.280.0040.00415.84
7.1.270.0090.00415.46
7.1.260.0000.01115.69
7.1.70.0000.00917.32
7.1.60.0030.00817.27
7.1.50.0090.01316.70
7.1.00.0070.07022.51
7.0.200.0120.00016.84
7.0.140.0070.06722.10
7.0.90.0630.08720.04
7.0.80.0470.06020.01
7.0.70.0470.05319.98
7.0.60.0570.08319.91
7.0.50.0600.06720.36
7.0.40.0070.06720.08
7.0.30.0100.04320.09
7.0.20.0030.05320.05
7.0.10.0070.07020.13
7.0.00.0130.08020.14
5.6.280.0030.07321.07
5.6.230.0170.06720.64
5.6.220.0070.07320.50
5.6.210.0030.06020.66
5.6.200.0230.06721.05
5.6.190.0030.06021.04
5.6.180.0070.08020.93
5.6.170.0100.08321.11
5.6.160.0000.08721.09
5.6.150.0270.07021.07
5.6.140.0100.05321.07
5.6.130.0100.07321.04
5.6.120.0130.07020.96
5.6.110.0070.09021.01
5.6.100.0170.06720.94
5.6.90.0070.08320.98
5.6.80.0230.06720.56
5.6.70.0200.07720.47
5.6.60.0130.07720.41
5.6.50.0100.04720.44
5.6.40.0100.04020.43
5.6.30.0100.08020.54
5.6.20.0030.05320.41
5.6.10.0130.07320.47
5.6.00.0100.07720.30
5.5.370.0100.07320.41
5.5.360.0070.05720.37
5.5.350.0030.05720.44
5.5.340.0030.09320.81
5.5.330.0070.05020.79
5.5.320.0130.06720.75
5.5.310.0130.08320.94
5.5.300.0100.04320.77
5.5.290.0100.08320.77
5.5.280.0000.08020.79
5.5.270.0030.08720.61
5.5.260.0030.05320.77
5.5.250.0070.07720.61
5.5.240.0100.07720.31
5.5.230.0170.07020.24
5.5.220.0070.05720.30
5.5.210.0170.07720.13
5.5.200.0100.07720.20
5.5.190.0130.07720.28
5.5.180.0070.06320.10
5.5.160.0070.04720.23
5.5.150.0030.07720.08
5.5.140.0070.07020.28
5.5.130.0070.07320.28
5.5.120.0030.07020.22
5.5.110.0030.08320.11
5.5.100.0000.05319.99
5.5.90.0130.06720.09
5.5.80.0030.04319.98
5.5.70.0030.04720.01
5.5.60.0100.05020.07
5.5.50.0130.07320.17
5.5.40.0100.04320.02
5.5.30.0130.07320.04
5.5.20.0130.04720.09
5.5.10.0070.08020.01
5.5.00.0070.06320.05
5.4.450.0100.07319.35
5.4.440.0100.05019.37
5.4.430.0070.07719.55
5.4.420.0100.06719.53
5.4.410.0070.06019.14
5.4.400.0070.07718.88
5.4.390.0030.07319.05
5.4.380.0070.05319.04
5.4.370.0000.08018.90
5.4.360.0170.07319.12
5.4.350.0170.06719.16
5.4.340.0130.07319.12
5.4.320.0100.06019.05
5.4.310.0070.05319.07
5.4.300.0100.07019.04
5.4.290.0100.05718.89
5.4.280.0070.07319.04
5.4.270.0070.04019.02
5.4.260.0100.07319.14
5.4.250.0070.07719.13
5.4.240.0200.07019.04
5.4.230.0100.07018.94
5.4.220.0170.07318.93
5.4.210.0100.07319.04
5.4.200.0100.05019.22
5.4.190.0070.07319.09
5.4.180.0130.07019.22
5.4.170.0130.05719.02
5.4.160.0100.07319.11
5.4.150.0100.06319.00
5.4.140.0130.04716.41
5.4.130.0000.08016.34
5.4.120.0030.05716.40
5.4.110.0070.08016.45
5.4.100.0100.07016.50
5.4.90.0100.06716.37
5.4.80.0100.07316.32
5.4.70.0070.05716.26
5.4.60.0130.07016.31
5.4.50.0100.07016.33
5.4.40.0130.06716.46
5.4.30.0070.07016.41
5.4.20.0100.07016.36
5.4.10.0100.05016.43
5.4.00.0000.05015.86
5.3.290.0070.07714.67
5.3.280.0130.04714.71
5.3.270.0070.07714.67
5.3.260.0070.05014.61
5.3.250.0070.07314.76
5.3.240.0070.07714.76
5.3.230.0100.08014.66
5.3.220.0070.07714.64
5.3.210.0070.04714.69
5.3.200.0100.07014.69
5.3.190.0170.04014.51
5.3.180.0100.06714.53
5.3.170.0030.04314.50
5.3.160.0130.04714.68
5.3.150.0070.05714.64
5.3.140.0070.07314.66
5.3.130.0070.04714.66
5.3.120.0030.07314.70
5.3.110.0000.08314.63
5.3.100.0030.04314.04
5.3.90.0070.03714.05
5.3.80.0170.06314.01
5.3.70.0130.04014.02
5.3.60.0030.04714.07
5.3.50.0030.07013.93
5.3.40.0200.06013.96
5.3.30.0130.07013.93
5.3.20.0100.07013.70
5.3.10.0100.03013.66
5.3.00.0030.07313.73
5.2.170.0000.03313.61
5.2.160.0000.05713.61
5.2.150.0000.05013.61
5.2.140.0000.06713.61
5.2.130.0030.06313.61
5.2.120.0000.04713.61
5.2.110.0130.05013.61
5.2.100.0000.06313.61
5.2.90.0070.03013.61
5.2.80.0030.05013.61
5.2.70.0070.03013.61
5.2.60.0070.04313.61
5.2.50.0000.03013.61
5.2.40.0070.02713.61
5.2.30.0030.02713.61
5.2.20.0000.03313.61
5.2.10.0030.02713.61
5.2.00.0030.03713.61
5.1.60.0030.02313.61
5.1.50.0000.02713.61
5.1.40.0070.02013.61
5.1.30.0000.02713.61
5.1.20.0000.02713.61
5.1.10.0000.02313.61
5.1.00.0000.02713.61
5.0.50.0070.01313.61
5.0.40.0000.02013.61
5.0.30.0100.02013.61
5.0.20.0000.02013.61
5.0.10.0070.01313.61
5.0.00.0000.03013.61
4.4.90.0000.01713.61
4.4.80.0000.01713.61
4.4.70.0000.01713.61
4.4.60.0030.01313.61
4.4.50.0030.02713.61
4.4.40.0000.02713.61
4.4.30.0000.01713.61
4.4.20.0030.01313.61
4.4.10.0030.01013.61
4.4.00.0000.02713.61
4.3.110.0030.02013.61
4.3.100.0030.02713.61
4.3.90.0000.01313.61
4.3.80.0030.02313.61
4.3.70.0000.01313.61
4.3.60.0070.00713.61
4.3.50.0000.02013.61
4.3.40.0000.03713.61
4.3.30.0030.03313.61
4.3.20.0000.01713.61
4.3.10.0000.01713.61
4.3.00.0000.01313.61

preferences:
58.59 ms | 401 KiB | 5 Q