public
Last active — forked from jongalloway/program.cs

  • Download Gist
program.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
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();
client.Headers.Add("Accept-Encoding", "gzip,deflate");
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));
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.