jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
What will be more costly, getting a new XHR object versus a new Image object? The result could lead to the decision whether to log data via XHR GET of a normal GET. Mind that an Image object could block the (on)load event, while XHR won't. So when the data will be send should also be considered within the decision.
var getXHR = function() {
if (window.XMLHttpRequest) {
getXHR = function() {
return new XMLHttpRequest;
};
return new XMLHttpRequest;
}
var http,
msxml = [
'Microsoft.XMLHTTP',
'MSXML2.XMLHTTP',
'MSXML2.XMLHTTP.3.0'
],
iterations = msxml.length;
for (iterations; iterations--;) {
try {
http = new ActiveXObject(msxml[iterations]);
getXHR = function() {
return new ActiveXObject(msxml[iterations]);
};
break;
}
catch(e) {}
}
return http;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Init XHR Object |
| ready |
Init Image Object |
| ready |
Init multiple XHR Objects |
| ready |
Init multiple Image Objects |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.