3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Handles Memcache Sessions * * @property Memcache $pool Memcache Object */ class MemcacheSessionModule /*implements \SessionHandlerInterface */ { const UNIX_PREFIX = 'unix://'; const FILE_PREFIX = 'file://'; const TCP_PREFIX = 'tcp://'; const SCHEME_FILE = 'file'; const SCHEME_TCP = 'tcp'; const SCHEME_UNIX = 'unix'; const ZERO_PORT = ':0'; /** * Our Memcache Pool * @var Memcache */ private $pool; public function __construct() { $this->pool = new Memcache; } public function close() { return $this->pool->close(); } public function destroy($sessionId) { } public function gc($maxLifetime) { } public function open($savePath, $name) { $serverList = self::parseSavePath($savePath); if (!$serverList) { return false; } foreach ($serverList as $serverInfo) { var_dump($serverInfo); $this->pool->addserver( $serverInfo['host'], $serverInfo['port'], $serverInfo['persistent'], $serverInfo['weight'], $serverInfo['timeout'], $serverInfo['retry_interval'] ); } return true; } public function read($sessionId) { } public function write($sessionId, $data) { } private static function parseSavePath($savePath) { if (empty($savePath)) { trigger_error( "Failed to parse session.save_path (empty save_path)", E_WARNING); return false; } $serverList = explode(',', $savePath); $return = array(); foreach ($serverList as $url) { $url = strtolower($url); // Swap unix:// to file:// for parse_url if (substr($url, 0, strlen(self::UNIX_PREFIX)) === self::UNIX_PREFIX) { $url = self::FILE_PREFIX . substr($url, strlen(self::UNIX_PREFIX)); } $parsedUrlData = parse_url($url); if (!$parsedUrlData) { trigger_error("Failed to parse session.save_path (unable to parse " . "url, url was '" . $url . "')", E_WARNING); return false; } // Init optional values $serverInfo = array( 'persistent' => null, 'weight' => null, 'timeout' => null, 'retry_interval' => null ); switch ($parsedUrlData['scheme']) { case self::SCHEME_FILE: if (substr($parsedUrlData['path'], -2) === self::ZERO_PORT) { $parsedUrlData['path'] = substr($parsedUrlData['path'], 0, -2); } $serverInfo['host'] = self::SCHEME_UNIX . $parsedUrlData['path']; $serverInfo['port'] = 0; break; case self::SCHEME_TCP: $serverInfo['host'] = self::SCHEME_TCP . $parsedUrlData['host']; if (array_key_exists('port', $parsedUrlData)) { $serverInfo['port'] = $parsedUrlData['port']; } else { $serverInfo['port'] = (int)ini_get('memcache.default_port'); } break; default: trigger_error("Failed to parse session.save_path (unknown protocol," . " url was '" . $url . "')", E_WARNING); return false; } if (array_key_exists('query', $parsedUrlData)) { $optionList = array(); parse_str($parsedUrlData['query'], $optionList); if (count($optionList) > 0) { foreach ($optionList as $key => $value) { switch ($key) { case 'persistent': $serverInfo[$key] = (bool)$value; break; case 'weight': case 'timeout': case 'retry_interval': $serverInfo[$key] = (int)$value; break; } } } } $return[] = $serverInfo; } return $return; } } $session = new MemcacheSessionModule; $session->open('unix:///var/run/memcache.sock?weight=123,tcp://127.0.0.1:11211?weight=1&persistent=1&timeout=4');

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.0130.00718.30
8.3.50.0070.00921.81
8.3.40.0150.00018.67
8.3.30.0180.00019.07
8.3.20.0050.00320.34
8.3.10.0040.00423.71
8.3.00.0110.00017.75
8.2.180.0090.00618.41
8.2.170.0040.01122.96
8.2.160.0090.00920.57
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00422.11
8.2.110.0000.01021.00
8.2.100.0110.00017.85
8.2.90.0030.00717.91
8.2.80.0000.00917.97
8.2.70.0000.00817.50
8.2.60.0040.00417.90
8.2.50.0000.00818.07
8.2.40.0050.00319.82
8.2.30.0070.00318.13
8.2.20.0060.00317.90
8.2.10.0000.00818.11
8.2.00.0050.00317.86
8.1.280.0120.00925.92
8.1.270.0060.00324.01
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0100.00022.05
8.1.230.0030.00920.99
8.1.220.0040.00417.74
8.1.210.0000.01118.77
8.1.200.0040.00417.23
8.1.190.0040.00417.22
8.1.180.0030.00518.10
8.1.170.0050.00318.52
8.1.160.0000.00722.00
8.1.150.0080.00018.82
8.1.140.0030.00517.38
8.1.130.0040.00417.29
8.1.120.0050.00217.30
8.1.110.0050.00217.44
8.1.100.0000.00717.37
8.1.90.0070.00317.38
8.1.80.0070.00017.25
8.1.70.0000.00717.35
8.1.60.0000.00817.54
8.1.50.0040.00417.54
8.1.40.0050.00317.46
8.1.30.0050.00317.46
8.1.20.0000.00817.61
8.1.10.0000.00817.46
8.1.00.0050.00217.39
8.0.300.0040.00420.19
8.0.290.0040.00416.88
8.0.280.0030.00318.35
8.0.270.0000.00717.25
8.0.260.0000.00716.88
8.0.250.0030.00517.02
8.0.240.0000.00717.01
8.0.230.0040.00417.00
8.0.220.0000.00717.01
8.0.210.0000.00716.86
8.0.200.0000.00717.07
8.0.190.0000.00717.06
8.0.180.0000.00717.00
8.0.170.0080.00016.81
8.0.160.0070.00016.83
8.0.150.0030.00616.91
8.0.140.0000.00816.90
8.0.130.0000.00613.38
8.0.120.0050.00316.91
8.0.110.0030.00616.86
8.0.100.0040.00416.77
8.0.90.0030.00516.75
8.0.80.0090.00616.95
8.0.70.0040.00416.98
8.0.60.0050.00316.90
8.0.50.0020.00516.88
8.0.30.0140.00717.22
8.0.20.0100.00817.40
8.0.10.0040.00416.80
8.0.00.0030.01617.01
7.4.330.0060.00015.00
7.4.320.0070.00016.30
7.4.300.0060.00016.57
7.4.290.0030.00316.48
7.4.280.0040.00416.60
7.4.270.0030.00616.49
7.4.260.0080.00016.59
7.4.250.0040.00416.43
7.4.240.0020.00616.49
7.4.230.0070.00016.58
7.4.220.0210.00416.53
7.4.210.0060.00916.48
7.4.200.0030.00516.49
7.4.160.0100.00716.43
7.4.150.0110.00717.40
7.4.140.0050.01217.86
7.4.130.0100.01016.64
7.4.120.0080.00816.62
7.4.110.0150.01116.69
7.4.100.0110.00916.34
7.4.90.0140.00516.70
7.4.80.0040.01819.39
7.4.70.0080.00816.38
7.4.60.0030.01316.41
7.4.50.0000.00416.61
7.4.40.0130.00416.43
7.4.30.0100.01016.67
7.4.00.0030.01214.99
7.3.330.0000.00513.22
7.3.320.0040.00413.45
7.3.310.0030.00316.46
7.3.300.0030.00316.32
7.3.290.0090.00616.43
7.3.280.0100.01016.45
7.3.270.0130.00617.40
7.3.260.0220.00316.71
7.3.250.0150.01016.41
7.3.240.0090.00916.36
7.3.230.0080.00916.60
7.3.210.0060.01216.51
7.3.200.0170.00919.39
7.3.190.0100.00716.55
7.3.180.0100.00616.55
7.3.170.0140.00316.44
7.3.160.0120.00916.39
7.3.120.0060.01314.57
7.3.110.0060.01214.64
7.3.100.0000.01214.88
7.3.90.0040.01114.61
7.3.80.0120.00314.75
7.3.70.0040.01414.98
7.3.60.0060.00314.83
7.3.50.0040.01114.69
7.3.40.0050.00514.92
7.3.30.0070.01014.70
7.3.20.0120.00416.55
7.3.10.0000.01216.62
7.3.00.0030.00616.41
7.2.330.0110.00516.61
7.2.320.0050.01116.63
7.2.310.0100.00616.56
7.2.300.0090.01216.36
7.2.290.0110.00716.47
7.2.250.0040.01814.93
7.2.240.0070.01514.59
7.2.230.0090.00914.71
7.2.220.0070.00714.96
7.2.210.0100.00614.46
7.2.200.0120.00414.81
7.2.190.0060.00614.94
7.2.180.0000.01514.82
7.2.170.0030.00615.04
7.2.60.0060.00916.78
7.2.00.0110.00319.25
7.1.330.0090.00615.50
7.1.320.0050.00315.53
7.1.310.0060.00915.43
7.1.300.0100.00715.75
7.1.290.0030.00615.64
7.1.280.0030.01215.48
7.1.270.0040.00815.60
7.1.260.0060.00615.35
7.1.200.0090.00315.76
7.1.100.0070.00317.80
7.1.70.0000.00816.70
7.1.60.0030.01019.32
7.1.50.0090.00616.90
7.1.00.0000.07722.27
7.0.200.0050.00216.73
7.0.140.0100.06722.10
7.0.60.0100.08019.98
7.0.50.0000.08017.91
7.0.40.0030.04720.18
7.0.30.0630.06020.08
7.0.20.0130.05320.09
7.0.10.0300.06320.30
7.0.00.0030.08720.22
5.6.280.0000.07021.13
5.6.210.0030.04320.51
5.6.200.0000.08718.16
5.6.190.0100.05020.61
5.6.180.0330.07020.47
5.6.170.0300.08020.52
5.6.160.0130.08020.46
5.6.150.0030.08718.16
5.6.140.0000.04318.25
5.6.130.0070.08018.18
5.6.120.0100.07321.13
5.6.110.0100.07021.15
5.6.100.0170.07320.92
5.6.90.0100.07721.03
5.6.80.0070.07720.40
5.5.350.0130.07020.38
5.5.340.0030.04317.94
5.5.330.0230.04320.31
5.5.320.0400.06320.31
5.5.310.0130.06320.29
5.5.300.0070.04717.95
5.5.290.0070.08318.08
5.5.280.0100.05320.98
5.5.270.0100.07720.76
5.5.260.0100.08320.79
5.5.250.0100.07720.64
5.5.240.0200.07720.36
5.4.450.0430.03319.22
5.4.440.0170.04319.27
5.4.430.0200.04319.47
5.4.420.0670.00019.36
5.4.410.0830.00019.44
5.4.400.0630.00019.13
5.4.390.0670.00019.11
5.4.380.0670.00019.13
5.4.370.0630.00019.02
5.4.360.0630.00019.21
5.4.350.0670.00019.04
5.4.340.0100.03912.04
5.4.320.0090.03412.53
5.4.310.0080.03612.52
5.4.300.0090.03412.53
5.4.290.0060.03812.52
5.4.280.0100.03212.43
5.4.270.0080.04012.42
5.4.260.0070.03712.42
5.4.250.0050.03912.42
5.4.240.0070.03712.42
5.4.230.0080.03612.41
5.4.220.0070.03512.41
5.4.210.0080.03512.41
5.4.200.0080.04912.41
5.4.190.0070.03712.41
5.4.180.0080.03912.41
5.4.170.0050.03812.43
5.4.160.0090.03312.41
5.4.150.0100.03212.41
5.4.140.0110.03712.10
5.4.130.0080.04712.09
5.4.120.0090.05112.04
5.4.110.0080.05012.04
5.4.100.0100.04912.04
5.4.90.0160.05712.04
5.4.80.0050.05612.04
5.4.70.0090.05012.04
5.4.60.0070.04512.04
5.4.50.0060.03712.04
5.4.40.0050.03712.02
5.4.30.0060.03612.02
5.4.20.0050.03712.02
5.4.10.0100.03512.02
5.4.00.0050.03711.52
5.3.290.0090.05612.80
5.3.280.0100.03512.72
5.3.270.0100.04012.73
5.3.260.0110.04212.72
5.3.250.0060.03812.73
5.3.240.0090.03812.72
5.3.230.0050.03812.71
5.3.220.0070.03612.69
5.3.210.0050.05212.68
5.3.200.0060.03712.68
5.3.190.0040.04112.68
5.3.180.0100.03412.68
5.3.170.0090.03412.69
5.3.160.0090.03412.68
5.3.150.0060.03812.68
5.3.140.0090.03412.68
5.3.130.0090.03712.66
5.3.120.0100.03412.67
5.3.110.0120.03612.67
5.3.100.0080.03812.16
5.3.90.0080.03612.14
5.3.80.0060.03712.14
5.3.70.0040.04112.13
5.3.60.0060.04012.12
5.3.50.0050.04312.07
5.3.40.0070.03612.07
5.3.30.0070.03312.03
5.3.20.0040.03711.80
5.3.10.0060.03411.77
5.3.00.0070.04011.76
5.2.170.0090.0469.27
5.2.160.0070.0299.27
5.2.150.0080.0309.27
5.2.140.0090.0329.26
5.2.130.0100.0369.23
5.2.120.0050.0309.23
5.2.110.0060.0309.23
5.2.100.0080.0259.23
5.2.90.0100.0289.22
5.2.80.0050.0359.22
5.2.70.0060.0299.22
5.2.60.0070.0309.18
5.2.50.0090.0269.14
5.2.40.0040.0309.12
5.2.30.0070.0299.09
5.2.20.0060.0309.08
5.2.10.0040.0318.99
5.2.00.0040.0328.85
5.1.60.0070.0238.14
5.1.50.0030.0288.14
5.1.40.0060.0238.11
5.1.30.0070.0248.46
5.1.20.0050.0268.48
5.1.10.0060.0258.21
5.1.00.0060.0258.21
5.0.50.0050.0206.69
5.0.40.0040.0216.55
5.0.30.0020.0346.36
5.0.20.0040.0236.34
5.0.10.0060.0216.31
5.0.00.0060.0296.31
4.4.90.0040.0144.78
4.4.80.0030.0154.75
4.4.70.0010.0174.75
4.4.60.0020.0164.75
4.4.50.0050.0174.77
4.4.40.0050.0314.71
4.4.30.0050.0224.76
4.4.20.0040.0194.84
4.4.10.0050.0144.85
4.4.00.0030.0264.76
4.3.110.0040.0144.67
4.3.100.0020.0164.66
4.3.90.0060.0114.64
4.3.80.0010.0264.59
4.3.70.0030.0184.63
4.3.60.0040.0154.63
4.3.50.0060.0144.63
4.3.40.0020.0314.54
4.3.30.0030.0153.30
4.3.20.0020.0163.29
4.3.10.0020.0153.23
4.3.00.0100.0109.89

preferences:
47.72 ms | 401 KiB | 5 Q