Skip to content

Commit

Permalink
A benchmark for a performance issue when removing a named property
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris-van-der-Wel committed Jul 26, 2015
1 parent 445f91e commit 457ff9c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion benchmark/dom/index.js
Expand Up @@ -3,5 +3,6 @@
module.exports = {
construction: require("./construction"),
"tree-modification": require("./tree-modification"),
"compare-document-position": require("./compare-document-position")
"compare-document-position": require("./compare-document-position"),
"named-properties": require("./named-properties")
};
34 changes: 34 additions & 0 deletions benchmark/dom/named-properties.js
@@ -0,0 +1,34 @@
"use strict";
const suite = require("../document-suite");

exports["setAttribute(): Remove a named property from window"] = function () {
const NODES = 1000;
let nodes;
let parent;

return suite({
setup: function (document) {
parent = document.createElement("div");

nodes = new Array(NODES);
for (let i = 0; i < NODES; ++i) {
const node = document.createElement("span");
nodes[i] = node;
node.setAttribute("id", "named" + i);
parent.appendChild(node);
}

document.body.appendChild(parent);
},
tearDown: function(document) {
document.body.removeChild(parent);
nodes = null;
parent = null;
},
fn: function () {
for (let i = 0; i < NODES; ++i) {
nodes[i].removeAttribute("id");
}
}
});
};

0 comments on commit 457ff9c

Please sign in to comment.