user friendliness overhead for remove attr

JavaScript performance comparison

Revision 2 of this test case created by John Bender

Info

These tests are meant to examine the benefits of removing user friendliness features in favor of performance. The test subject is $.removeAttr.

Preparation code

<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.

Testing in unknown unknown
Test Ops/sec
friendly
window.testSet
  .removeAttr( "foo" )
  .removeAttr( "bar" )
  .removeAttr( "baz" );
 
pending…
unfriendly
window.testSet
  .removeAttrSimple( "foo" )
  .removeAttrSimple( "bar" )
  .removeAttrSimple( "baz" );
 
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:

0 comments

Add a comment