Files
rrweb/packages/rrweb/test/html/benchmark-dom-mutation.html
yz-yu a43d4e4255 Introduce benchmark tests and improve snapshot attributes traversing (#897)
* housekeeping: refine test utils

* setup benchmark tests

* improve snapshot attributes loop perf
2022-05-14 14:52:26 +08:00

28 lines
804 B
HTML

<html>
<body></body>
<script>
window.workload = () => {
const branches = 1000;
const depth = 10;
const frag = document.createDocumentFragment();
for (let b = 0; b < branches; b++) {
const node = document.createElement('div');
let d = 0;
node.setAttribute('branch', b.toString());
node.setAttribute('depth', d.toString());
let current = node;
while (d < depth - 1) {
d++;
const child = document.createElement('div');
child.setAttribute('branch', b.toString());
child.setAttribute('depth', d.toString());
current.appendChild(child);
current = child;
}
frag.appendChild(node);
}
document.body.appendChild(frag);
};
</script>
</html>