Skip to content

Instantly share code, notes, and snippets.

@sad-pixel
Last active August 29, 2015 14:04
Show Gist options
  • Save sad-pixel/375948fbcb33764b2e71 to your computer and use it in GitHub Desktop.
Save sad-pixel/375948fbcb33764b2e71 to your computer and use it in GitHub Desktop.
jsTest - The One Stop Shop for CDN Benchmarking
#!/bin/bash
function speedTest { local the_speed=$( wget -O /dev/null "http://$1" 2>&1 | awk '/\/dev\/null/ {speed = $3 $4} END {gsub(/\(|\)/,"",speed); print speed}');echo $the_speed;};echo "jsTest.sh by IshanDS www.ishands.cf";echo "";cdnjs=$(speedTest "cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js");echo "Speed from CDNJs: $cdnjs";google=$(speedTest "ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js");echo "Speed from Google CDN: $google";jsdelivr=$(speedTest "cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js");echo "Speed from jsDelivr: $jsdelivr";maxcdn=$(speedTest "oss.maxcdn.com/jquery/2.1.1/jquery.min.js");echo "Speed from MaxCDN: $maxcdn";jquery=$(speedTest "code.jquery.com/jquery-2.1.1.min.js");echo "Speed from Jquery CDN: $jquery";microsoft=$(speedTest "ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.1.min.js");echo "Speed from Microsoft CDN: $microsoft";echo "";echo "Thank you for using jsTest.sh"
#!/bin/bash
#
# jstest.sh - Bash Script for testing the speed of
# Various Javascript CDNs
# Such as CDNJs, jsDelivr etc.
# Arguments : None
# Author : Ishan Das Sharma aka ishands
# Website : www.ishands.cf
# Date : 20th July 2014
# License : WTFPL
function speedTest {
# Download the URL and Process the D-Speed from it.
# Processing code is completely ripped off from
# http://freevps.us/downloads/bench.sh with
# some edits because
# I'm very bad at awk
#
# Accepts: One (1) Argument cotaining the URL of the file
# Returns: One (1) String Value containing the Speed..
local the_speed=$( wget -O /dev/null "http://$1" 2>&1 | awk '/\/dev\/null/ {speed = $3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
echo $the_speed
}
echo "jsTest.sh by IshanDS www.ishands.cf"
echo ""
# CDNJs
cdnjs=$(speedTest "cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js")
echo "Speed from CDNJs: $cdnjs"
# Google CDN
google=$(speedTest "ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js")
echo "Speed from Google CDN: $google"
# jsDelivr
jsdelivr=$(speedTest "cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js")
echo "Speed from jsDelivr: $jsdelivr"
# MaxCDN OSS
maxcdn=$(speedTest "oss.maxcdn.com/jquery/2.1.1/jquery.min.js")
echo "Speed from MaxCDN: $maxcdn"
# Jquery CDN
jquery=$(speedTest "code.jquery.com/jquery-2.1.1.min.js")
echo "Speed from Jquery CDN: $jquery"
# Microsoft CDN
microsoft=$(speedTest "ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.1.min.js")
echo "Speed from Microsoft CDN: $microsoft"
echo ""
echo "Thank you for using jsTest.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment