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
<span id="elem1" class="a b c d" />
<span id="elem2" class="b" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var reset = function() {
$('#elem1').attr('class', 'a b c d');
$('#elem2').attr('class', 'b');
}
var f1 = function(el, cls) {
reset();
var $el = $('#' + el);
if (!$el.hasClass(cls)) {
$el.removeClass('a b c d').addClass(cls);
}
};
var f2 = function(el, cls) {
reset();
$('#' + el).removeClass('a b c d').addClass(cls);
};
var f3 = function(el, cls) {
reset();
$('#' + el).attr('class', cls);
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
with has test |
| ready |
without has test |
| ready |
attr |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.