3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<EOT [ { "file": "/jquery/2.1.1/jquery.min.js", "md5": "d021c983bd6e7291b43a5cc1fb2ebe99" }, { "file": "/g/jquery@2.1.0,angularjs@1.2.14(angular.min.js+angular-resource.min.js+angular-animate.min.js+angular-cookies.min.js+angular-route.min.js+angular-sanitize.min.js)", "md5": "57e021c8c8b5e5b262ad8e072180fc22" }, { "file": "/g/jquery@2.1.1,d3js@3.4.10,typeahead.js@0.10.2,underscorejs@1.6.0,spinjs@1.3.0,handlebarsjs@1.3.0(handlebars.min.js)", "md5": "e723f9074b6ceab9f74f5d191c497245" }, { "file": "/bootstrap/3.2.0/css/bootstrap.min.css", "md5": "385b964b68acb68d23cb43a5218fade9" }, { "file": "/jquery/1.4/jquery.min.js", "md5": "73a9c334c5ca71d70d092b42064f6476" }, { "file": "/fancybox/2.1.5/helpers/fancybox_buttons.png", "md5": "b448080f8615e664b7788c7003803b59" }, { "file": "/foundation/5.3.0/foundation.zip", "md5": "2687f8c45789171eae115649a52ec464" }, { "file": "/normalize/1/normalize.css", "md5": "f1780870594b8948c02270c3c5408437" }, { "file": "/jquery/latest/jquery.min.js", "dynamic": { "name": "jquery", "pathFormat": "/jquery/{$version}/jquery.min.js" } }, { "file": "/angularjs/latest/angular.min.js", "dynamic": { "name": "angularjs", "pathFormat": "/angularjs/{$version}/angular.min.js" } }, { "file": "/g/jquery.fileupload@7(jquery/js/jquery.fileupload.js)", "md5": "5114585e67c495043e7f72e47bf9cefb" }, { "file": "/g/chosen", "dynamic": { "name": "chosen", "pathFormat": "/chosen/{$version}/chosen.jquery.min.js", "trimWhitespace": true } } ] EOT; $config = json_decode($json); function curl($url){ if (function_exists('curl_version')){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close ($ch); return $result; } else { return file_get_contents($url); } } $apiServer = 'jsdelivr-api.dak.netdna-cdn.com'; $originServer = 'origin.jsdelivr.net'; // Host defaults to http://cdn.jsdelivr.net if (empty($_GET['host'])) { $host = 'http://cdn.jsdelivr.net'; } else { $host = 'http://' . $_GET['host']; } $passed = 0; $failed = 0; foreach ($config as $test) { if (!empty($test->dynamic)) { // Ask the api for the latest version of the project $apiResult = json_decode(curl("http://{$apiServer}/v1/jsdelivr/libraries?fields=lastversion&name=" . $test->dynamic->name)); $staticPath = strtr($test->dynamic->pathFormat, array('{$version}' => $apiResult[0]->lastversion)); if (isset($test->dynamic->trimWhitespace) && ($test->dynamic->trimWhitespace === true)) { $fileMD5 = md5(trim(curl($host . $test->file))); } else { $fileMD5 = md5(curl($host . $test->file)); } $staticMD5 = md5(curl($host . $staticPath)); // Test if it matches MD5 of static file if ($fileMD5 == $staticMD5) { // Test if it matches origin $originMD5 = md5(curl("http://{$originServer}" . $staticPath)); if($fileMD5 == $originMD5) { $passed += 1; echo '[PASS] ', $test->file, "\n"; } else { $failed += 1; echo '[FAIL] ', $test->file, "\n"; echo '-> Origin mismatch', "\n"; } } else { $failed += 1; echo '[FAIL] ', $test->file, "\n"; echo '-> Checksum mismatch', "\n"; } } else { $fileMD5 = md5(curl($host . $test->file)); // Test if it matches MD5 in config if ($fileMD5 == $test->md5) { // Test if it matches origin $originMD5 = md5(curl("http://{$originServer}" . $test->file)); if($fileMD5 == $originMD5) { $passed += 1; echo '[PASS] ', $test->file, "\n"; } else { $failed += 1; echo '[FAIL] ', $test->file, "\n"; echo '-> Origin mismatch', "\n"; } } else { $failed += 1; echo '[FAIL] ', $test->file, "\n"; echo '-> Checksum mismatch', "\n"; } } // Don't trigger DDoS firewalls, etc sleep(0.75); } // Let's spin the asset wheel ten times, twice! function array_mt_rand($array) { // PHP should use mt_rand for array_rand... return $array[mt_rand(0, count($array) - 1)]; } // This section randomly tests origin-cdn matching $allProjects = json_decode(curl("http://{$apiServer}/v1/jsdelivr/libraries/?fields=name,assets")); $pickedFiles = array(); $i = 0; while ($i++ < 10) { // Much files. Such random. Wow. $randomProject = array_mt_rand($allProjects); $randomName = $randomProject->name; $randomAssetGroup = array_mt_rand($randomProject->assets); $randomVersion = $randomAssetGroup->version; $randomFile = array_mt_rand($randomAssetGroup->files); $pickedFiles[] = "/{$randomName}/{$randomVersion}/{$randomFile}"; } foreach ($pickedFiles as $filePath) { $fileMD5 = md5(curl($host . $filePath)); // Test if it matches origin $originMD5 = md5(curl("http://{$originServer}" . $filePath)); if($fileMD5 == $originMD5) { $passed += 1; echo '[PASS] ', $filePath, "\n"; } else { $failed += 1; echo '[FAIL] ', $filePath, "\n"; echo '-> Origin mismatch', "\n"; } // Don't trigger DDoS firewalls, etc sleep(0.75); } // This section randomly tests latest version matching for mainfiles $allProjects = json_decode(curl("http://{$apiServer}/v1/jsdelivr/libraries/?fields=name,mainfile,lastversion")); $pickedFiles = array(); $i = 0; while ($i++ < 10) { $randomProject = array_mt_rand($allProjects); $randomName = $randomProject->name; $randomMainfile = $randomProject->mainfile; $randomLastVersion = $randomProject->lastversion; if (empty($randomMainfile)) { $i--; } else { $pickedFiles[] = array( 'latestPath' => "/{$randomName}/latest/{$randomMainfile}", 'staticPath' => "/{$randomName}/{$randomLastVersion}/{$randomMainfile}" ); } } foreach ($pickedFiles as $fileInfo) { // Test if it matches MD5 of static file $fileMD5 = md5(curl($host . $fileInfo['latestPath'])); $staticMD5 = md5(curl($host . $fileInfo['staticPath'])); if ($fileMD5 == $staticMD5) { // Test if it matches origin $originMD5 = md5(curl("http://{$originServer}" . $fileInfo['staticPath'])); if($fileMD5 == $originMD5) { $passed += 1; echo '[PASS] ', $fileInfo['latestPath'], "\n"; } else { $failed += 1; echo '[FAIL] ', $fileInfo['latestPath'], "\n"; echo '-> Origin mismatch', "\n"; } } else { $failed += 1; echo '[FAIL] ', $fileInfo['latestPath'], "\n"; echo '-> Checksum mismatch', "\n"; } } echo $passed, ' tests passed, ', $failed, ' tests failed', "\n";

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.01018.57
8.3.50.0120.01022.11
8.3.40.0160.00019.29
8.3.30.0120.00419.50
8.3.20.0040.00420.62
8.3.10.0040.00424.03
8.3.00.0000.00919.46
8.2.180.0110.01117.25
8.2.170.0040.01222.96
8.2.160.0070.00720.77
8.2.150.0060.00324.18
8.2.140.0090.00024.66
8.2.130.0060.00326.16
8.2.120.0040.00419.74
8.2.110.0030.00721.29
8.2.100.0060.00618.22
8.2.90.0030.00519.44
8.2.80.0030.00618.00
8.2.70.0060.00618.00
8.2.60.0060.00918.18
8.2.50.0030.00618.07
8.2.40.0000.00920.20
8.2.30.0050.00318.60
8.2.20.0040.00418.16
8.2.10.0040.00418.51
8.2.00.0030.00619.83
8.1.280.0120.00325.92
8.1.270.0060.00324.09
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0040.00721.12
8.1.230.0060.00624.11
8.1.220.0080.00017.89
8.1.210.0040.00418.77
8.1.200.0000.01117.61
8.1.190.0030.00617.63
8.1.180.0030.00618.10
8.1.170.0040.00718.89
8.1.160.0080.00022.30
8.1.150.0040.00419.02
8.1.140.0060.00317.91
8.1.130.0000.00818.27
8.1.120.0000.00917.66
8.1.110.0000.00917.88
8.1.100.0040.00417.74
8.1.90.0060.00317.69
8.1.80.0000.00817.73
8.1.70.0070.00017.69
8.1.60.0030.00617.82
8.1.50.0000.00917.82
8.1.40.0030.00617.80
8.1.30.0000.00917.91
8.1.20.0060.00317.93
8.1.10.0040.00417.83
8.1.00.0050.00317.93
8.0.300.0030.00618.77
8.0.290.0040.00417.25
8.0.280.0000.00818.97
8.0.270.0030.00617.72
8.0.260.0050.00317.67
8.0.250.0080.00017.33
8.0.240.0070.00017.30
8.0.230.0000.00717.22
8.0.220.0000.00817.24
8.0.210.0000.00917.40
8.0.200.0040.00417.32
8.0.190.0040.00417.31
8.0.180.0040.00417.44
8.0.170.0050.00517.29
8.0.160.0030.00517.17
8.0.150.0000.00817.20
8.0.140.0030.00617.29
8.0.130.0000.00613.87
8.0.120.0050.00517.40
8.0.110.0030.00617.52
8.0.100.0050.00517.49
8.0.90.0000.00917.37
8.0.80.0030.01617.38
8.0.70.0090.00017.36
8.0.60.0070.00317.38
8.0.50.0060.00317.32
8.0.30.0140.01317.33
8.0.20.0160.00817.48
8.0.10.0050.00517.36
8.0.00.0120.01217.22
7.4.330.0100.00015.43
7.4.320.0060.01216.87
7.4.300.0060.01116.80
7.4.290.0000.01416.63
7.4.280.0060.01316.76
7.4.270.0060.01116.68
7.4.260.0060.01216.74
7.4.250.0190.00016.62
7.4.240.0140.00216.76
7.4.230.0040.00916.79
7.4.220.0210.01316.88
7.4.210.0130.02116.77
7.4.200.0100.00516.67
7.4.160.0440.00816.87
7.4.150.0270.01517.40
7.4.140.0310.02717.86
7.4.130.0230.01416.96
7.4.120.0380.01016.89
7.4.110.0550.00716.74
7.4.100.0530.01316.83
7.4.90.0190.01816.74
7.4.80.0500.01219.39
7.4.70.0480.02416.85
7.4.60.0310.01316.87
7.4.50.0040.00816.77
7.4.40.0370.02816.96
7.4.30.0220.01816.69
7.4.00.0110.01215.20
7.3.330.0080.00013.73
7.3.320.0000.01213.77
7.3.310.0000.01616.63
7.3.300.0000.01816.74
7.3.290.0240.01616.72
7.3.280.0190.02516.71
7.3.270.0400.01117.40
7.3.260.0320.02416.84
7.3.250.0300.02216.81
7.3.240.0380.00916.70
7.3.230.0370.01616.86
7.3.210.0850.03716.79
7.3.200.0380.01119.39
7.3.190.0290.01216.63
7.3.180.0190.01316.64
7.3.170.1370.03516.74
7.3.160.0310.01316.95
7.3.120.0140.01015.39
7.2.330.0410.01016.95
7.2.320.0300.00317.07
7.2.310.0320.01616.92
7.2.300.0520.01817.00
7.2.290.0610.03916.92
7.2.60.0220.01017.25
7.2.00.0090.00619.66
7.1.200.0110.00816.02
7.1.100.0100.01018.51
7.1.70.0000.01116.93
7.1.60.0130.01319.70
7.1.50.0140.01317.51
7.0.200.0080.00316.83

preferences:
38.71 ms | 401 KiB | 5 Q