3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php /** Uses PHP 5.4 **/ ini_set('display_errors', true); set_time_limit(0); require_once __DIR__ . "/vendor/autoload.php"; /** Parse the config into an array **/ $config = (new Symfony\Component\Yaml\Yaml)->parse(__DIR__ . "/config/config.yml"); /** Generate an array of requests **/ $requests = []; for ($i = 0; $i < $config['num_requests']; $i++) { foreach ($config['endpoints'] as $endpoint) { $requests[] = $config['base_url'] . $endpoint; } } /** We need to track how many requests remain so we can stop the reactor when finished **/ $requestCountRemaining = count($requests); // ----------------------------------------------------- /** Create a new HTTP client (abstraction) and reactor (for async awesomeness) **/ $reactor = (new Alert\ReactorFactory)->select(); $client = new Artax\AsyncClient($reactor); /** Event-driven programming doesn't mean line-by-line any more! **/ $onResponse = function(Artax\Response $response, Artax\Request $request) use (&$requestCountRemaining, $reactor) { echo $request->getUri(), ' -- '; echo 'HTTP/', $response->getProtocol(), ' ', $response->getStatus(), ' ', $response->getReason(), "\n"; unset($request); if (!--$requestCountRemaining) { $reactor->stop(); } }; $onError = function(Exception $e, Artax\Request $request) use (&$requestCountRemaining, $reactor) { echo $request->getUri(), " failed (", get_class($e), ") : '" . $e->getMessage() . "'\n"; if (!--$requestCountRemaining) { $reactor->stop(); } }; /** Schedule this stuff to happen when the reactor starts **/ $reactor->immediately(function() use ($client, $config, $requests, $onResponse, $onError, $requests) { $onAuthResponse = function(Artax\Response $response, Artax\Request $request) use ($client, $config, $onResponse, $onError) { $authTokens = $response->getHeader('WWW-Authenticate')[0]; $explode = explode(',', $authTokens); $realm = rtrim(str_replace('Digest realm="', '', $explode[0]), '"'); $qop = rtrim(str_replace('qop="', '', $explode[1]), '"'); $nonce = rtrim(str_replace('nonce="', '', $explode[2]), '"'); $uri = $request->getUri(); $cnonce = md5(uniqid()); $nc = 1; $A1 = md5(sprintf("%s:%s:%s", $config['auth']['username'], $realm, $config['auth']['password'])); $A2 = md5(sprintf("%s:%s", 'GET', $uri)); $hash = md5(sprintf("%s:%s:%s:%s:%s:%s", $A1, $nonce, $nc, $cnonce, $qop, $A2)); $auth = sprintf( 'Digest nonce=%s,nc=%s,cnonce=%s,qop=%s,username=%s,uri=%s,response=%s', $nonce, $nc, $cnonce, $qop, $config['auth']['username'], $uri, $hash ); $request = (new Artax\Request)->setMethod('GET')->setUri($uri)->setHeader('Authorization', $auth); $client->request($request, $onResponse, $onError); }; foreach ($requests as $key => $uri) { $request = (new Artax\Request)->setMethod('GET')->setUri($uri); $client->request($request, $onAuthResponse, $onError); } /** Remember, event-driven. So this will actually happen first.. LOL! **/ echo 'Requesting ', count($requests), ' URIs ...', "\n"; }); /** Start the reactor **/ $reactor->run();

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)
5.4.290.0070.04712.49
5.4.280.0120.04112.39
5.4.270.0070.03812.39
5.4.260.0100.04412.39
5.4.250.0100.04212.39
5.4.240.0080.04212.39
5.4.230.0100.04612.38
5.4.220.0080.04912.38
5.4.210.0120.03912.38
5.4.200.0090.05812.38
5.4.190.0090.04712.38
5.4.180.0060.04312.38
5.4.170.0100.03912.38
5.4.160.0100.04212.38
5.4.150.0090.04312.38
5.4.140.0100.04712.07
5.4.130.0080.04712.05
5.4.120.0090.04512.01
5.4.110.0080.04912.01
5.4.100.0130.05712.01
5.4.90.0050.05012.01
5.4.80.0130.05512.01
5.4.70.0100.05012.01
5.4.60.0140.04712.01
5.4.50.0140.04512.01
5.4.40.0110.05412.00
5.4.30.0090.04511.99
5.4.20.0120.05211.99
5.4.10.0110.05511.99
5.4.00.0110.05311.48
5.3.280.0090.05812.71
5.3.270.0140.06212.72
5.3.260.0150.06512.72
5.3.250.0120.04712.72
5.3.240.0140.04612.72
5.3.230.0090.04312.71
5.3.220.0120.04612.68
5.3.210.0100.04312.68
5.3.200.0090.05612.68
5.3.190.0090.04412.68
5.3.180.0090.04212.67
5.3.170.0090.04912.67
5.3.160.0060.03912.67
5.3.150.0110.03812.67
5.3.140.0070.03612.66
5.3.130.0090.04112.66
5.3.120.0070.04112.65
5.3.110.0080.04512.66
5.3.100.0100.05612.12
5.3.90.0070.04812.08
5.3.80.0070.04412.08
5.3.70.0150.06712.08
5.3.60.0080.04112.06
5.3.50.0070.04112.00
5.3.40.0090.04512.00
5.3.30.0110.04311.95
5.3.20.0090.04711.73
5.3.10.0080.04311.70
5.3.00.0120.05811.68

preferences:
141.23 ms | 1394 KiB | 7 Q