-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add benchmark for addList worst case performance
- Loading branch information
1 parent
58c9104
commit e6e87d2
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/rrweb/test/html/benchmark-dom-mutation-add-reorder.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<html> | ||
<body> | ||
<select id="select"></select> | ||
</body> | ||
<script> | ||
window.workload = () => { | ||
const optionCount = 10000; | ||
const options = []; | ||
for (let i = 0; i < optionCount; ++i) { | ||
const value = `${i}`; | ||
options.push({ value, label: value }); | ||
} | ||
const frag = document.createDocumentFragment(); | ||
const select = document.getElementById('select'); | ||
const parent = select.parentNode; | ||
parent.removeChild(select); | ||
for (let o of options) { | ||
const option = document.createElement('option'); | ||
option.value = o.value; | ||
option.textContent = o.label; | ||
o.optionElement = option; | ||
frag.appendChild(option); | ||
} | ||
select.appendChild(frag); | ||
parent.appendChild(select); | ||
// re-shuffle the options | ||
options.sort(() => Math.random() - 0.5); | ||
for (var o of options) { | ||
o.optionElement.parentNode.appendChild(o.optionElement); | ||
} | ||
}; | ||
</script> | ||
</html> |