3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting( -1); session_start(); interface Singleton_Interface { public static function getInstance(); } abstract class Singleton implements Singleton_Interface { public function __clone() { throw new Exception( 'Clone is not allowed.' ); } } class master extends Singleton implements Singleton_Interface { private $r; private static $instance; public static function getInstance( $params=array( ) ) { if( !isset(self::$instance) ) { $c = __CLASS__; self::$instance = new $c($params); } return self::$instance; } public function knock() { echo 'call ' . __METHOD__ . PHP_EOL; } public function __construct($r=false) { $this->r = $r; echo __METHOD__ . PHP_EOL; } public function __destruct() { echo __METHOD__ . PHP_EOL; if (method_exists($this->r, 'knock')) { $this->r->knock(); } $_SESSION['x'] = __METHOD__; } } class b extends Singleton implements Singleton_Interface { private $r; private static $instance; public static function getInstance( $params=array( ) ) { if( !isset(self::$instance) ) { $c = __CLASS__; self::$instance = new $c($params); } return self::$instance; } public function knock() { echo 'call ' . __METHOD__ . PHP_EOL; } public function __construct($r=false) { $this->r = $r; echo __METHOD__ . PHP_EOL; } public function __destruct() { echo __METHOD__ . PHP_EOL; if (method_exists($this->r, 'knock')) { $this->r->knock(); } $_SESSION['y'] = __METHOD__; } } header( 'content-type: text/plain' ); echo 'session:'; print_r($_SESSION); $master = master::getInstance(); $b = b::getInstance($master); // calls master->knock() on destruction $master->knock(); $b->knock(); echo 'done' . PHP_EOL;

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.0180.00418.68
8.3.50.0150.00322.12
8.3.40.0040.01118.92
8.3.30.0070.00719.23
8.3.20.0140.00020.16
8.3.10.0050.00323.66
8.3.00.0050.00320.96
8.2.180.0160.00318.44
8.2.170.0040.01122.96
8.2.160.0120.00320.61
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0190.00026.16
8.2.120.0000.00819.35
8.2.110.0030.00622.14
8.2.100.0090.00320.48
8.2.90.0000.00819.21
8.2.80.0060.00317.97
8.2.70.0030.00617.63
8.2.60.0080.00018.05
8.2.50.0040.00418.07
8.2.40.0090.00020.07
8.2.30.0050.00318.22
8.2.20.0070.00017.84
8.2.10.0040.00418.27
8.2.00.0000.00917.71
8.1.280.0140.00325.92
8.1.270.0040.00424.04
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0000.01023.96
8.1.230.0000.01119.14
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0030.00617.48
8.1.190.0040.00817.36
8.1.180.0000.00818.10
8.1.170.0030.00518.54
8.1.160.0020.00521.95
8.1.150.0040.00418.59
8.1.140.0000.00717.54
8.1.130.0040.00419.67
8.1.120.0030.00517.55
8.1.110.0030.00617.51
8.1.100.0000.00717.47
8.1.90.0040.00417.56
8.1.80.0050.00317.53
8.1.70.0050.00317.37
8.1.60.0030.00617.49
8.1.50.0030.00517.54
8.1.40.0000.00817.50
8.1.30.0000.00817.51
8.1.20.0080.00017.57
8.1.10.0030.00517.51
8.1.00.0080.00017.41
8.0.300.0030.00618.77
8.0.290.0000.00716.75
8.0.280.0000.00718.52
8.0.270.0030.00316.87
8.0.260.0000.00717.32
8.0.250.0030.00316.96
8.0.240.0040.00416.97
8.0.230.0070.00016.98
8.0.220.0000.00717.07
8.0.210.0040.00417.02
8.0.200.0000.00617.04
8.0.190.0000.00816.93
8.0.180.0000.00817.07
8.0.170.0040.00416.94
8.0.160.0000.00817.04
8.0.150.0040.00416.97
8.0.140.0000.00716.85
8.0.130.0000.00613.44
8.0.120.0000.00716.86
8.0.110.0000.00816.92
8.0.100.0000.00816.95
8.0.90.0030.00517.04
8.0.80.0090.00617.03
8.0.70.0000.00717.05
8.0.60.0030.00516.95
8.0.50.0040.00416.76
8.0.30.0080.01316.96
8.0.20.0180.00517.45
8.0.10.0090.00017.03
8.0.00.0110.00716.83
7.4.330.0030.00315.12
7.4.320.0000.00616.63
7.4.300.0000.00716.58
7.4.290.0040.00416.59
7.4.280.0060.00316.49
7.4.270.0040.00416.54
7.4.260.0060.00313.28
7.4.250.0000.00716.46
7.4.240.0020.00516.54
7.4.230.0070.00016.51
7.4.220.0060.01216.55
7.4.210.0170.00016.59
7.4.200.0080.00016.28
7.4.160.0100.00716.66
7.4.150.0120.01217.40
7.4.140.0070.01417.86
7.4.130.0100.00716.54
7.4.120.0110.00616.67
7.4.110.0070.01716.39
7.4.100.0160.00616.45
7.4.90.0110.00616.41
7.4.80.0140.00919.39
7.4.70.0090.00916.44
7.4.60.0110.00716.69
7.4.50.0040.00016.54
7.4.40.0080.00816.67
7.4.30.0100.00716.52
7.4.10.0090.00715.13
7.4.00.0070.01015.13
7.3.330.0000.00713.38
7.3.320.0050.00013.48
7.3.310.0000.00716.29
7.3.300.0000.00716.44
7.3.290.0110.00316.42
7.3.280.0070.01116.39
7.3.270.0070.01117.40
7.3.260.0090.00916.64
7.3.250.0100.01016.54
7.3.240.0110.00816.63
7.3.230.0130.00316.57
7.3.210.0000.01716.46
7.3.200.0100.00719.39
7.3.190.0110.00816.72
7.3.180.0030.01316.46
7.3.170.0120.00416.63
7.3.160.0040.01116.68
7.3.130.0070.01214.99
7.3.120.0110.00714.92
7.3.110.0070.01014.85
7.3.100.0030.01214.86
7.3.90.0050.00815.08
7.3.80.0030.00614.69
7.3.70.0060.00614.92
7.3.60.0050.01014.90
7.3.50.0040.00714.74
7.3.40.0060.00814.93
7.3.30.0060.01014.95
7.3.20.0070.00716.61
7.3.10.0080.00816.61
7.3.00.0070.00816.62
7.2.330.0100.00716.52
7.2.320.0130.00316.79
7.2.310.0140.00316.56
7.2.300.0120.00816.89
7.2.290.0100.01316.87
7.2.260.0080.01015.01
7.2.250.0060.01114.97
7.2.240.0090.00615.04
7.2.230.0080.00915.29
7.2.220.0050.00914.92
7.2.210.0030.00915.02
7.2.200.0070.00915.21
7.2.190.0070.00514.96
7.2.180.0080.00715.02
7.2.170.0050.00715.01
7.2.160.0040.00914.89
7.2.150.0060.00917.03
7.2.140.0030.00816.99
7.2.130.0080.00716.59
7.2.120.0070.01216.71
7.2.110.0090.00716.86
7.2.100.0080.00916.57
7.2.90.0070.00916.73
7.2.80.0080.00816.81
7.2.70.0070.01016.82
7.2.60.0050.00816.80
7.2.50.0040.01316.79
7.2.40.0050.00616.93
7.2.30.0070.01016.80
7.2.20.0080.00816.60
7.2.10.0070.00916.92
7.2.00.0070.00816.88
7.1.330.0080.00715.91
7.1.320.0100.00315.64
7.1.310.0060.00915.91
7.1.300.0070.00315.71
7.1.290.0030.00815.78
7.1.280.0060.01015.91
7.1.270.0040.00515.97
7.1.260.0080.00315.77
7.1.250.0060.00815.42
7.1.240.0050.00615.93
7.1.230.0020.01015.69
7.1.220.0060.00815.73
7.1.210.0100.00515.83
7.1.200.0030.01015.77
7.1.190.0060.00815.79
7.1.180.0030.00715.68
7.1.170.0090.00615.55
7.1.160.0050.00615.74
7.1.150.0070.00715.75
7.1.140.0020.00815.97
7.1.130.0070.00715.97
7.1.120.0060.00815.82
7.1.110.0040.00615.97
7.1.100.0080.00515.57
7.1.90.0050.00915.90
7.1.80.0040.01115.90
7.1.70.0100.00816.17
7.1.60.0080.00917.12
7.1.50.0080.00716.15
7.1.40.0100.00515.77
7.1.30.0040.00915.59
7.1.20.0030.00815.66
7.1.10.0040.00915.73
7.1.00.0040.03018.00
7.0.330.0050.00915.17
7.0.320.0040.00815.53
7.0.310.0060.00615.13
7.0.300.0050.00915.37
7.0.290.0020.01115.55
7.0.280.0030.00815.48
7.0.270.0060.00515.50
7.0.260.0050.00815.43
7.0.250.0050.00715.41
7.0.240.0060.00415.56
7.0.230.0060.00515.54
7.0.220.0040.01015.37
7.0.210.0050.00815.44
7.0.200.0060.00615.93
7.0.190.0030.01015.60
7.0.180.0070.00815.37
7.0.170.0100.00515.48
7.0.160.0060.00915.45
7.0.150.0050.00915.34
7.0.140.0030.03017.64
7.0.130.0060.00815.50
7.0.120.0070.00515.49
7.0.110.0050.01115.45
7.0.100.0040.00915.57
7.0.90.0020.01015.37
7.0.80.0140.00115.29
7.0.70.0070.02117.61
7.0.60.0030.03317.59
7.0.50.0080.02317.76
7.0.40.0050.03215.56
7.0.30.0080.01615.63
7.0.20.0070.03215.47
7.0.10.0030.02915.74
7.0.00.0060.02715.68
5.6.400.0030.00814.47
5.6.390.0050.01214.66
5.6.380.0100.00514.31
5.6.370.0030.00914.39
5.6.360.0070.00514.33
5.6.350.0040.01014.73
5.6.340.0060.00914.53
5.6.330.0060.00614.63
5.6.320.0030.01014.63
5.6.310.0120.00414.62
5.6.300.0050.00814.50
5.6.290.0040.01114.22
5.6.280.0030.03016.78
5.6.270.0070.01014.49
5.6.260.0060.00714.46
5.6.250.0030.01314.64
5.6.240.0060.00614.56
5.6.230.0030.00914.78
5.6.220.0050.02316.60
5.6.210.0030.03516.50
5.6.200.0060.02916.66
5.6.190.0070.02216.77
5.6.180.0080.02916.73
5.6.170.0050.03216.75
5.6.160.0070.02116.63
5.6.150.0010.02416.61
5.6.140.0020.03616.55
5.6.130.0010.03516.79
5.6.120.0030.03416.67
5.6.110.0090.03016.83
5.6.100.0080.02216.78
5.6.90.0050.03516.49
5.6.80.0060.02016.47
5.6.70.0060.03316.45
5.6.60.0030.03316.53
5.6.50.0050.03216.36
5.6.40.0040.03316.38
5.6.30.0010.03316.52
5.6.20.0050.03116.39
5.6.10.0020.02616.27
5.6.00.0060.03216.50
5.5.380.0050.01014.60
5.5.370.0020.01314.39
5.5.360.0050.03316.31
5.5.350.0040.03016.47
5.5.340.0070.02716.52
5.5.330.0020.03916.56
5.5.320.0060.01616.66
5.5.310.0040.03516.50
5.5.300.0090.02416.56
5.5.290.0050.02316.55
5.5.280.0030.03116.76
5.5.270.0060.03116.72
5.5.260.0080.03416.41
5.5.250.0070.03116.54
5.5.240.0080.03016.32
5.5.230.0100.02616.37
5.5.220.0030.03316.18
5.5.210.0070.02916.20
5.5.200.0100.02816.41
5.5.190.0060.03216.34
5.5.180.0060.03116.34
5.5.170.0050.00814.39
5.5.160.0050.02416.25
5.5.150.0070.02716.12
5.5.140.0060.03216.37
5.5.130.0060.03416.32
5.5.120.0090.02016.54
5.5.110.0070.02916.43
5.5.100.0070.02216.26
5.5.90.0060.03016.19
5.5.80.0050.02116.34
5.5.70.0050.03016.37
5.5.60.0080.03016.22
5.5.50.0090.03016.36
5.5.40.0020.03316.16
5.5.30.0050.03316.36
5.5.20.0080.03016.37
5.5.10.0070.03216.20
5.5.00.0060.02116.35
5.4.450.0050.03014.47
5.4.440.0040.03314.46
5.4.430.0010.03414.39
5.4.420.0070.02014.43
5.4.410.0060.02914.43
5.4.400.0040.02914.27
5.4.390.0050.02814.36
5.4.380.0040.02414.26
5.4.370.0050.02814.32
5.4.360.0060.02814.32
5.4.350.0080.02514.27
5.4.340.0050.03214.33
5.4.330.0040.00911.97
5.4.320.0040.03214.35
5.4.310.0010.03014.27
5.4.300.0070.02214.27
5.4.290.0080.02414.28
5.4.280.0030.03214.32
5.4.270.0060.02314.36
5.4.260.0050.02514.27
5.4.250.0040.02314.28
5.4.240.0050.02514.37
5.4.230.0020.02914.33
5.4.220.0070.02414.37
5.4.210.0040.02914.27
5.4.200.0020.03314.27
5.4.190.0020.03214.32
5.4.180.0040.02814.38
5.4.170.0070.02614.32
5.4.160.0060.02114.31
5.4.150.0070.02214.32
5.4.140.0040.03113.47
5.4.130.0020.02713.50
5.4.120.0030.03013.47
5.4.110.0090.02513.50
5.4.100.0040.02513.44
5.4.90.0030.03013.49
5.4.80.0030.02813.48
5.4.70.0050.02213.42
5.4.60.0020.03113.43
5.4.50.0030.02313.43
5.4.40.0030.03013.44
5.4.30.0050.02713.47
5.4.20.0050.02413.43
5.4.10.0050.01913.47
5.4.00.0050.02713.28
5.3.290.0050.02912.86
5.3.280.0040.02912.90
5.3.270.0030.02412.88
5.3.260.0040.02112.84
5.3.250.0040.02912.86
5.3.240.0040.02112.89
5.3.230.0060.03012.84
5.3.220.0030.03112.82
5.3.210.0030.03212.87
5.3.200.0030.02912.87
5.3.190.0020.03212.86
5.3.180.0050.02012.83
5.3.170.0020.03112.82
5.3.160.0030.03112.86
5.3.150.0020.03212.88
5.3.140.0020.03212.88
5.3.130.0040.02512.84
5.3.120.0060.02812.88
5.3.110.0020.02812.81
5.3.100.0060.02612.67
5.3.90.0040.01812.68
5.3.80.0040.02912.69
5.3.70.0050.02912.71
5.3.60.0010.02112.67
5.3.50.0050.01512.68
5.3.40.0030.02912.67
5.3.30.0040.02212.65
5.3.20.0050.02912.54
5.3.10.0000.02912.54
5.3.00.0040.02912.50
5.2.170.0070.06312.15
5.2.160.0070.02712.15
5.2.150.0030.05312.15
5.2.140.0030.03712.15
5.2.130.0030.06012.15
5.2.120.0000.03712.15
5.2.110.0000.05012.15
5.2.100.0070.05712.15
5.2.90.0030.02712.15
5.2.80.0030.05312.15
5.2.70.0100.04712.15
5.2.60.0070.06012.15
5.2.50.0030.06312.15
5.2.40.0070.06012.15
5.2.30.0070.05312.15
5.2.20.0000.06312.15
5.2.10.0000.06012.15
5.2.00.0100.05712.15
5.1.60.0030.05312.15
5.1.50.0030.04312.15
5.1.40.0000.05312.15
5.1.30.0070.04012.15
5.1.20.0030.05712.15
5.1.10.0030.05312.15
5.1.00.0030.05012.15
5.0.50.0070.03312.15
5.0.40.0030.04012.15
5.0.30.0030.06712.15
5.0.20.0030.02712.15
5.0.10.0070.04012.15
5.0.00.0030.06312.15
4.4.90.0030.03312.15
4.4.80.0000.03312.15
4.4.70.0000.04012.15
4.4.60.0000.03012.15
4.4.50.0000.04012.15
4.4.40.0000.05312.15
4.4.30.0030.03012.15
4.4.20.0000.03712.15
4.4.10.0000.03012.15
4.4.00.0070.05312.15
4.3.110.0000.03712.15
4.3.100.0000.03712.15
4.3.90.0000.03712.15
4.3.80.0070.05012.15
4.3.70.0030.02012.15
4.3.60.0030.02012.15
4.3.50.0100.02312.15
4.3.40.0000.04712.15
4.3.30.0030.02712.15
4.3.20.0000.04012.15
4.3.10.0000.03312.15
4.3.00.0000.03712.15

preferences:
47.03 ms | 401 KiB | 5 Q