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
Like stoyan's data-attribute speed test, but only checking getters (since that's the far more common operation in my experience).
<div id="mydiv"></div>
var div = document.getElementById('mydiv');
var Data = function() {
var warehouse = {};
var count = 1;
return {
reset: function() {
count = 1;
warehouse = {};
},
set: function (dom, data) {
if (!dom.__data) {
dom.__data = "hello" + count++;
}
warehouse[dom.__data] = data;
},
get: function(dom) {
return warehouse[dom.__data];
}
};
}();
div.setAttribute('data-po', 'to');
div.setAttribute('data-ta', 'ma');
div.setAttribute('data-to', 'to');
Data.set(div, {po: 'to', ta: 'ma', to: 'to'});
div.setAttribute('data-po', null);
div.setAttribute('data-ta', null);
div.setAttribute('data-to', null);
div.setAttribute('__data', null);
Data.reset();
Ready to run.
Test | Ops/sec | |
---|---|---|
old school setAttribute |
| ready |
DIY Data |
| ready |
HTML5 dataset |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.