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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="el"></div>
<script>
// 'el-lo
var $el = $('#el');
var el = $el[0];
var get; // access holder, so that dead stores aren't so easily culled off.
// Store only 19 strings to test.
// In real code, there usually are not very many
// unique keys that get accessed and mutated.
// It needs to be odd so that after counter%limit loops,
// the attr/prop/data accessors return values.
// This also shakes up the key/value pairs.
var counter, limit = 19;
var rnd = [];
// Pre-create all strings unique, just to make sure nothing funny happens.
for (var i = 0; i < limit; i++) {
rnd[i] = 'X-' + i + '-' + Math.floor(Math.random() * 1001);
}
function nextKey() { return rnd[counter++ % limit]; }
function nextVal() { return rnd[counter++ % limit]; }
</script>
counter = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery.fn.attr |
| ready |
jQuery.fn.prop |
| ready |
jQuery.fn.data |
| ready |
jQuery.data(el) |
| ready |
jQuery.data($el) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.