chained sequence or composition removeAttr
JavaScript performance comparison
Info
Tests the relative performance of jQuery's removeAttr with a small performance modification chained three times, one loop over the elements with three invocations, and a composed version invoked once. All tests are with set of 10 elements.
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-1.7.2.js"></script>
<script src="https://raw.github.com/johnbender/auto-jquery-optimization-paper/master/perf/removeattr/removeAttr.js"></script>
<script>
window.testElementCount = 10;
</script>
<script src="https://raw.github.com/johnbender/auto-jquery-optimization-paper/master/perf/removeattr/setup.js"></script>
<script>
Benchmark.prototype.setup = function() {
// cache the test sets
window.testSet = $( "[data-test]" );
// add the attribute and data to be removed
window.testSet
.attr("foo", "bar")
.attr("bar", "bang")
.attr("baz", "bak");
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
chained |
|
pending… |
three invocations |
|
pending… |
composed |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by John Bender
- Revision 2: published by John Bender
0 comments