-
-
Save jongalloway/984018 to your computer and use it in GitHub Desktop.
Quick hack to test download times, see http://blog.stackoverflow.com/2011/05/the-speed-of-light-sucks/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Net; | |
namespace ConsoleApplication1 { | |
internal class Program { | |
private const int COUNT = 20; | |
private static void Main() { | |
var urls = new[] { | |
"http://sstatic.net/js/full.js", | |
"http://sstatic.stackexchange.netdna-cdn.com/js/full.js", | |
"http://d1d5ue6vu5b30i.cloudfront.net/js/full.js", | |
"http://wac.43df.edgecastcdn.net/8043DF/sstatic/js/full.js" | |
}; | |
foreach (var url in urls) { | |
MeasureUrl(url); | |
} | |
Console.ReadLine(); | |
} | |
private static void MeasureUrl(string url) { | |
var client = new WebClient(); | |
var sw = Stopwatch.StartNew(); | |
var rand = new Random(); | |
for (var i = 0; i < COUNT; ++i) { | |
client.DownloadData(string.Format("{0}?rand={1}", url, rand.Next())); | |
} | |
sw.Stop(); | |
Console.WriteLine("URL {0} took {1} ms", url, (sw.ElapsedMilliseconds/COUNT)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment