create vs clone (v2)

Revision 2 of this benchmark created on


Description

Compare the performance of creating a new element vs cloning a node.

Preparation HTML

<script>
  var template = document.createElement('p');
  var children = document.createElement('p');
  for (var i = 0; i < 20; i++) {
   children.appendChild(document.createText('Hello world'));
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Create Element
document.createElement('p');
ready
Clone Node
template.cloneNode(true);
ready
Clone node with children
children.cloneNode(true);
ready

Revisions

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