title: Correctly measure download speed javascript
body: <p>To measure client download speed, I'm using an ajax get call to a text file of known size, and using the javascript date prototype's getTime() function to measure how long it took. I chose this for its simplicity, but for some reason, this is returning vastly slower numbers than I get with speedtest.net. Is there a more accurate way to do this?</p>
  
  <pre><code>var ajaxTime = new Date().getTime();
  var request = jQuery.ajax({
                      url: "/eventdata/(default)/system_diagnostics/lorem.txt?s=" + ajaxTime,
                      type: "GET",
                      success: function(result) {//success
                          var totalTime = new Date().getTime()-ajaxTime;
                          var mbps = fileSize/(totalTime/1000);
                          mbps = mbps.toFixed(2);
                          nDLSpeedMbps = mbps;
  </code></pre>
  
  <p>Where fileSize is the size of the text file in megabits.</p>
  
  <p>The only thing I can think of is that the browser is occupied doing other things that use up bandwidth, but I don't know what. There is an upload test (another ajax call) on the same page, but that doesn't fire off until further down in the success function, after the download ajax call is finished and nDLSpeedMbps has been calculated.</p>