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::UNIX_PREFIX . $parsedUrlData['path']; $serverInfo['port'] = 0; break; case self::SCHEME_TCP: $serverInfo['host'] = self::TCP_PREFIX . $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.0070.00718.46
8.3.50.0100.01022.05
8.3.40.0150.00318.67
8.3.30.0110.00419.22
8.3.20.0080.00020.33
8.3.10.0050.00323.55
8.3.00.0060.00317.63
8.2.180.0110.00418.66
8.2.170.0110.00722.96
8.2.160.0060.01220.70
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00022.09
8.2.110.0050.00520.94
8.2.100.0080.00417.91
8.2.90.0030.00617.66
8.2.80.0000.00817.97
8.2.70.0000.00917.63
8.2.60.0040.00417.91
8.2.50.0050.00318.07
8.2.40.0060.00319.76
8.2.30.0080.00018.04
8.2.20.0000.00817.91
8.2.10.0040.00418.04
8.2.00.0000.00817.69
8.1.280.0120.00625.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0060.00322.02
8.1.230.0000.01120.89
8.1.220.0000.00817.74
8.1.210.0090.00018.77
8.1.200.0030.00617.13
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0050.00318.41
8.1.160.0070.00021.99
8.1.150.0050.00218.77
8.1.140.0050.00217.33
8.1.130.0030.00317.82
8.1.120.0050.00317.46
8.1.110.0000.00817.27
8.1.100.0040.00417.44
8.1.90.0030.00617.40
8.1.80.0050.00317.35
8.1.70.0000.00817.27
8.1.60.0030.00617.60
8.1.50.0080.00017.39
8.1.40.0000.00717.39
8.1.30.0030.00517.65
8.1.20.0000.00817.66
8.1.10.0000.00917.43
8.1.00.0030.00617.48
8.0.300.0000.00820.15
8.0.290.0040.00416.88
8.0.280.0040.00418.41
8.0.270.0000.00817.19
8.0.260.0000.00617.25
8.0.250.0000.00717.00
8.0.240.0040.00417.00
8.0.230.0000.00716.98
8.0.220.0000.00716.99
8.0.210.0030.00316.89
8.0.200.0030.00616.97
8.0.190.0040.00416.91
8.0.180.0000.00717.02
8.0.170.0040.00416.92
8.0.160.0000.00816.83
8.0.150.0030.00316.93
8.0.140.0060.00316.95
8.0.130.0000.00613.30
8.0.120.0050.00316.86
8.0.110.0070.00016.95
8.0.100.0000.00816.95
8.0.90.0070.00016.92
8.0.80.0060.01016.88
8.0.70.0030.00517.02
8.0.60.0040.00416.99
8.0.50.0030.00517.01
8.0.30.0050.01717.17
8.0.20.0110.01017.40
8.0.10.0040.00417.04
8.0.00.0110.00916.88
7.4.330.0000.00515.03
7.4.320.0030.00316.45
7.4.300.0000.00616.45
7.4.290.0030.00316.48
7.4.280.0020.00516.50
7.4.270.0040.00416.64
7.4.260.0000.00716.55
7.4.250.0040.00416.43
7.4.240.0040.00316.55
7.4.230.0000.00716.70
7.4.220.0090.01016.48
7.4.210.0120.00816.56
7.4.200.0080.00016.38
7.4.160.0070.01416.48
7.4.150.0130.00617.40
7.4.140.0120.00517.86
7.4.130.0090.00916.53
7.4.120.0160.00416.46
7.4.110.0100.01016.62
7.4.100.0060.01216.52
7.4.90.0110.00716.57
7.4.80.0100.01419.39
7.4.70.0060.01216.54
7.4.60.0000.01516.38
7.4.50.0040.00416.36
7.4.40.0130.00316.59
7.4.30.0030.01316.53
7.4.00.0070.00915.02
7.3.330.0050.00013.47
7.3.320.0040.00413.41
7.3.310.0030.00316.32
7.3.300.0020.00516.35
7.3.290.0110.00416.43
7.3.280.0090.00916.45
7.3.270.0080.00917.40
7.3.260.0090.00916.49
7.3.250.0110.00516.47
7.3.240.0100.00716.47
7.3.230.0060.01216.56
7.3.210.0130.00616.46
7.3.200.0150.00319.39
7.3.190.0060.01216.43
7.3.180.0000.01616.55
7.3.170.0140.00316.68
7.3.160.0090.01316.51
7.3.120.0070.01015.02
7.3.110.0140.00314.89
7.3.100.0030.01314.89
7.3.90.0060.00614.88
7.3.80.0070.00714.91
7.3.70.0060.00314.89
7.3.60.0000.01014.86
7.3.50.0030.01215.00
7.3.40.0030.01314.80
7.3.30.0000.01114.86
7.3.20.0030.01216.77
7.3.10.0030.00916.54
7.3.00.0030.01416.68
7.2.330.0070.01116.53
7.2.320.0030.01416.51
7.2.310.0140.00716.60
7.2.300.0120.00616.40
7.2.290.0100.00716.71
7.2.250.0120.00914.86
7.2.240.0100.01015.02
7.2.230.0090.00615.11
7.2.220.0060.00914.70
7.2.210.0060.01215.04
7.2.200.0060.00614.64
7.2.190.0090.00914.99
7.2.180.0090.00614.97
7.2.170.0040.01414.70
7.2.60.0100.00316.77
7.2.00.0100.00319.40
7.1.330.0030.00915.36
7.1.320.0040.01115.66
7.1.310.0060.01015.55
7.1.300.0030.01415.75
7.1.290.0130.00015.57
7.1.280.0080.00015.66
7.1.270.0090.00315.65
7.1.260.0060.00415.59
7.1.200.0020.00515.59
7.1.100.0100.00617.70
7.1.70.0040.00417.04
7.1.60.0070.00719.32
7.1.50.0090.00316.61
7.1.00.0070.07322.54
7.0.200.0060.01016.81
7.0.140.0030.07321.99
7.0.60.0030.07020.00
7.0.50.0130.07317.93
7.0.40.0130.08020.20
7.0.30.0470.04720.21
7.0.20.0200.08720.19
7.0.10.0070.08320.12
7.0.00.0030.04020.16
5.6.280.0030.07321.02
5.6.210.0000.04320.66
5.6.200.0130.07718.29
5.6.190.0100.08320.63
5.6.180.0400.06020.65
5.6.170.0270.03720.39
5.6.160.0100.08020.71
5.6.150.0000.08018.18
5.6.140.0030.08318.16
5.6.130.0070.09018.26
5.6.120.0000.04720.79
5.6.110.0130.08021.03
5.6.100.0070.03721.05
5.6.90.0100.08021.11
5.6.80.0000.08720.43
5.5.350.0170.07720.42
5.5.340.0070.05017.94
5.5.330.0030.05320.57
5.5.320.0270.05320.30
5.5.310.0200.03720.27
5.5.300.0170.07018.07
5.5.290.0000.06718.01
5.5.280.0070.05720.71
5.5.270.0000.09720.75
5.5.260.0030.08720.89
5.5.250.0100.06720.66
5.5.240.0200.07720.31
5.4.450.0330.04019.27
5.4.440.0400.04319.48
5.4.430.0270.04319.62
5.4.420.0670.00019.42
5.4.410.0630.00019.57
5.4.400.0630.00019.26
5.4.390.0630.00019.02
5.4.380.0670.00019.24
5.4.370.0600.00019.17
5.4.360.0730.00019.17
5.4.350.0670.00019.05
5.4.340.0070.03512.04
5.4.320.0090.04212.53
5.4.310.0070.04412.52
5.4.300.0090.03612.53
5.4.290.0080.03712.52
5.4.280.0090.03312.43
5.4.270.0040.03812.43
5.4.260.0060.03712.43
5.4.250.0050.04012.42
5.4.240.0080.03512.42
5.4.230.0070.04312.41
5.4.220.0090.03512.41
5.4.210.0070.03512.41
5.4.200.0080.03512.41
5.4.190.0030.03812.41
5.4.180.0080.03512.41
5.4.170.0100.03612.42
5.4.160.0080.04612.42
5.4.150.0130.04312.41
5.4.140.0110.05012.09
5.4.130.0120.04512.09
5.4.120.0110.04512.05
5.4.110.0080.04512.04
5.4.100.0070.04412.04
5.4.90.0060.05012.04
5.4.80.0090.04212.04
5.4.70.0040.03712.04
5.4.60.0040.03612.04
5.4.50.0080.03212.04
5.4.40.0030.03712.03
5.4.30.0060.03612.02
5.4.20.0050.04512.02
5.4.10.0100.05112.02
5.4.00.0120.04811.51
5.3.290.0090.05812.80
5.3.280.0120.05212.71
5.3.270.0100.05212.73
5.3.260.0070.05812.73
5.3.250.0070.05312.72
5.3.240.0090.05412.73
5.3.230.0100.04812.71
5.3.220.0100.04012.69
5.3.210.0150.04012.69
5.3.200.0090.04212.68
5.3.190.0120.03212.68
5.3.180.0140.02912.68
5.3.170.0160.02812.68
5.3.160.0090.03712.68
5.3.150.0110.03312.68
5.3.140.0110.03412.68
5.3.130.0070.04312.66
5.3.120.0080.04312.67
5.3.110.0100.04412.67
5.3.100.0090.03612.18
5.3.90.0090.03412.14
5.3.80.0030.04012.14
5.3.70.0050.03812.13
5.3.60.0060.04112.12
5.3.50.0080.03612.07
5.3.40.0120.04012.07
5.3.30.0050.03912.02
5.3.20.0070.03411.80
5.3.10.0070.03411.77
5.3.00.0100.03211.76
5.2.170.0060.0299.27
5.2.160.0060.0289.27
5.2.150.0110.0319.27
5.2.140.0090.0279.27
5.2.130.0100.0279.22
5.2.120.0040.0309.22
5.2.110.0070.0349.23
5.2.100.0060.0279.22
5.2.90.0060.0399.22
5.2.80.0050.0319.22
5.2.70.0040.0319.22
5.2.60.0060.0309.18
5.2.50.0060.0329.14
5.2.40.0110.0289.11
5.2.30.0050.0299.10
5.2.20.0080.0309.09
5.2.10.0060.0268.99
5.2.00.0040.0308.85
5.1.60.0130.0198.14
5.1.50.0060.0238.13
5.1.40.0060.0238.12
5.1.30.0080.0238.46
5.1.20.0050.0308.48
5.1.10.0070.0238.21
5.1.00.0040.0288.21
5.0.50.0040.0206.69
5.0.40.0050.0196.55
5.0.30.0060.0286.36
5.0.20.0060.0176.34
5.0.10.0070.0176.31
5.0.00.0040.0356.30
4.4.90.0020.0204.78
4.4.80.0050.0134.75
4.4.70.0050.0134.76
4.4.60.0050.0134.76
4.4.50.0050.0134.77
4.4.40.0050.0224.71
4.4.30.0050.0134.76
4.4.20.0060.0134.84
4.4.10.0080.0104.85
4.4.00.0020.0324.76
4.3.110.0040.0144.67
4.3.100.0020.0154.66
4.3.90.0030.0144.64
4.3.80.0020.0254.58
4.3.70.0010.0174.63
4.3.60.0030.0144.62
4.3.50.0020.0184.63
4.3.40.0030.0234.54
4.3.30.0020.0163.30
4.3.20.0010.0163.28
4.3.10.0010.0163.24
4.3.00.0030.0209.90

preferences:
44.54 ms | 400 KiB | 5 Q