Create button w/attributes vs createElement or cloneElement

JavaScript performance comparison

Test case created by Sean Collins

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var test_element = document.createElement('button');
  test_element.setAttribute('type', 'button');

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Create new button with attributes
var test_element2 = document.createElement('button');
test_element2.setAttribute('type', 'button');
pending…
Clone an existing element with attributes
var test_element3 = test_element.cloneNode(false);
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments