Skip to content

Instantly share code, notes, and snippets.

@talitapagani
Created May 16, 2014 00:36
Show Gist options
  • Save talitapagani/8505c8014e14f26b2795 to your computer and use it in GitHub Desktop.
Save talitapagani/8505c8014e14f26b2795 to your computer and use it in GitHub Desktop.
// As seen on http://www.html5rocks.com/en/tutorials/webperformance/usertiming/
var reqCount = 0;
var myReq = new XMLHttpRequest();
myReq.open('GET', url, true);
myReq.onload = function(e) {
window.performance.mark('mark_end_xhr');
reqCnt++;
window.performance.measure('measure_xhr_' + reqCnt, 'mark_start_xhr', 'mark_end_xhr');
do_something(e.responseText);
}
window.performance.mark('mark_start_xhr');
myReq.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment