Skip to content

Instantly share code, notes, and snippets.

@shawnweisfeld
Created June 25, 2014 13:18
Show Gist options
  • Save shawnweisfeld/278ac6601807cc67ca18 to your computer and use it in GitHub Desktop.
Save shawnweisfeld/278ac6601807cc67ca18 to your computer and use it in GitHub Desktop.
ping a Azure CDN endpoint to see how fast you can get the file and record the results.
static void Main(string[] args)
{
var url = "http://az590556.vo.msecnd.net/app/ec951196-2be1-4539-9e8f-3fc9f59590a9/client.js";
while (true)
{
using (HttpClient client = new HttpClient())
{
var sw = new Stopwatch();
sw.Start();
var result = client.GetAsync(url).Result;
sw.Stop();
IEnumerable<string> cache;
string cacheString = "NONE";
if (result.Headers.TryGetValues("X-Cache", out cache))
{
cacheString = string.Join("-", cache);
}
var message = string.Format("{0:G},{1},{2},{3}", System.DateTime.Now, result.StatusCode, sw.ElapsedMilliseconds, cacheString);
Console.WriteLine(message);
File.AppendAllText("result.txt", message + Environment.NewLine);
}
System.Threading.Thread.Sleep(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment