@ 2014-07-17T14:18:23Z <?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";
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.013 0.010 18.57 8.3.5 0.012 0.010 22.11 8.3.4 0.016 0.000 19.29 8.3.3 0.012 0.004 19.50 8.3.2 0.004 0.004 20.62 8.3.1 0.004 0.004 24.03 8.3.0 0.000 0.009 19.46 8.2.18 0.011 0.011 17.25 8.2.17 0.004 0.012 22.96 8.2.16 0.007 0.007 20.77 8.2.15 0.006 0.003 24.18 8.2.14 0.009 0.000 24.66 8.2.13 0.006 0.003 26.16 8.2.12 0.004 0.004 19.74 8.2.11 0.003 0.007 21.29 8.2.10 0.006 0.006 18.22 8.2.9 0.003 0.005 19.44 8.2.8 0.003 0.006 18.00 8.2.7 0.006 0.006 18.00 8.2.6 0.006 0.009 18.18 8.2.5 0.003 0.006 18.07 8.2.4 0.000 0.009 20.20 8.2.3 0.005 0.003 18.60 8.2.2 0.004 0.004 18.16 8.2.1 0.004 0.004 18.51 8.2.0 0.003 0.006 19.83 8.1.28 0.012 0.003 25.92 8.1.27 0.006 0.003 24.09 8.1.26 0.008 0.000 26.35 8.1.25 0.006 0.003 28.09 8.1.24 0.004 0.007 21.12 8.1.23 0.006 0.006 24.11 8.1.22 0.008 0.000 17.89 8.1.21 0.004 0.004 18.77 8.1.20 0.000 0.011 17.61 8.1.19 0.003 0.006 17.63 8.1.18 0.003 0.006 18.10 8.1.17 0.004 0.007 18.89 8.1.16 0.008 0.000 22.30 8.1.15 0.004 0.004 19.02 8.1.14 0.006 0.003 17.91 8.1.13 0.000 0.008 18.27 8.1.12 0.000 0.009 17.66 8.1.11 0.000 0.009 17.88 8.1.10 0.004 0.004 17.74 8.1.9 0.006 0.003 17.69 8.1.8 0.000 0.008 17.73 8.1.7 0.007 0.000 17.69 8.1.6 0.003 0.006 17.82 8.1.5 0.000 0.009 17.82 8.1.4 0.003 0.006 17.80 8.1.3 0.000 0.009 17.91 8.1.2 0.006 0.003 17.93 8.1.1 0.004 0.004 17.83 8.1.0 0.005 0.003 17.93 8.0.30 0.003 0.006 18.77 8.0.29 0.004 0.004 17.25 8.0.28 0.000 0.008 18.97 8.0.27 0.003 0.006 17.72 8.0.26 0.005 0.003 17.67 8.0.25 0.008 0.000 17.33 8.0.24 0.007 0.000 17.30 8.0.23 0.000 0.007 17.22 8.0.22 0.000 0.008 17.24 8.0.21 0.000 0.009 17.40 8.0.20 0.004 0.004 17.32 8.0.19 0.004 0.004 17.31 8.0.18 0.004 0.004 17.44 8.0.17 0.005 0.005 17.29 8.0.16 0.003 0.005 17.17 8.0.15 0.000 0.008 17.20 8.0.14 0.003 0.006 17.29 8.0.13 0.000 0.006 13.87 8.0.12 0.005 0.005 17.40 8.0.11 0.003 0.006 17.52 8.0.10 0.005 0.005 17.49 8.0.9 0.000 0.009 17.37 8.0.8 0.003 0.016 17.38 8.0.7 0.009 0.000 17.36 8.0.6 0.007 0.003 17.38 8.0.5 0.006 0.003 17.32 8.0.3 0.014 0.013 17.33 8.0.2 0.016 0.008 17.48 8.0.1 0.005 0.005 17.36 8.0.0 0.012 0.012 17.22 7.4.33 0.010 0.000 15.43 7.4.32 0.006 0.012 16.87 7.4.30 0.006 0.011 16.80 7.4.29 0.000 0.014 16.63 7.4.28 0.006 0.013 16.76 7.4.27 0.006 0.011 16.68 7.4.26 0.006 0.012 16.74 7.4.25 0.019 0.000 16.62 7.4.24 0.014 0.002 16.76 7.4.23 0.004 0.009 16.79 7.4.22 0.021 0.013 16.88 7.4.21 0.013 0.021 16.77 7.4.20 0.010 0.005 16.67 7.4.16 0.044 0.008 16.87 7.4.15 0.027 0.015 17.40 7.4.14 0.031 0.027 17.86 7.4.13 0.023 0.014 16.96 7.4.12 0.038 0.010 16.89 7.4.11 0.055 0.007 16.74 7.4.10 0.053 0.013 16.83 7.4.9 0.019 0.018 16.74 7.4.8 0.050 0.012 19.39 7.4.7 0.048 0.024 16.85 7.4.6 0.031 0.013 16.87 7.4.5 0.004 0.008 16.77 7.4.4 0.037 0.028 16.96 7.4.3 0.022 0.018 16.69 7.4.0 0.011 0.012 15.20 7.3.33 0.008 0.000 13.73 7.3.32 0.000 0.012 13.77 7.3.31 0.000 0.016 16.63 7.3.30 0.000 0.018 16.74 7.3.29 0.024 0.016 16.72 7.3.28 0.019 0.025 16.71 7.3.27 0.040 0.011 17.40 7.3.26 0.032 0.024 16.84 7.3.25 0.030 0.022 16.81 7.3.24 0.038 0.009 16.70 7.3.23 0.037 0.016 16.86 7.3.21 0.085 0.037 16.79 7.3.20 0.038 0.011 19.39 7.3.19 0.029 0.012 16.63 7.3.18 0.019 0.013 16.64 7.3.17 0.137 0.035 16.74 7.3.16 0.031 0.013 16.95 7.3.12 0.014 0.010 15.39 7.2.33 0.041 0.010 16.95 7.2.32 0.030 0.003 17.07 7.2.31 0.032 0.016 16.92 7.2.30 0.052 0.018 17.00 7.2.29 0.061 0.039 16.92 7.2.6 0.022 0.010 17.25 7.2.0 0.009 0.006 19.66 7.1.20 0.011 0.008 16.02 7.1.10 0.010 0.010 18.51 7.1.7 0.000 0.011 16.93 7.1.6 0.013 0.013 19.70 7.1.5 0.014 0.013 17.51 7.0.20 0.008 0.003 16.83
preferences:dark mode live preview
38.71 ms | 401 KiB | 5 Q