var start, stop;
var XHR = ("onload" in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest;
var xhr = new XHR();
// (2) запрос на другой домен :)
xhr.open('GET', 'http://anywhere.com/request', true);
start = (new Date()).getTime();
xhr.onload = function() {
alert( this.responseText );
stop = (new Date()).getTime();
document.getElementById("demo").innerHTML=stop - start;
}
xhr.onerror = function() {
alert( 'Ошибка ' + this.status );
}
xhr.send();
Правильно ли так высчитывать время выполнения запроса?