perf: record processMutation (#1214)
* perf: record processMutation * Create mean-tips-impress.md * Apply formatting changes
This commit is contained in:
5
.changeset/mean-tips-impress.md
Normal file
5
.changeset/mean-tips-impress.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'rrweb': patch
|
||||
---
|
||||
|
||||
perf: optimize the performance of record in processMutation phase
|
||||
@@ -656,6 +656,9 @@ export default class MutationBuffer {
|
||||
// this node was already recorded in other buffer, ignore it
|
||||
if (this.processedNodeManager.inOtherBuffer(n, this)) return;
|
||||
|
||||
// if n is added to set, there is no need to travel it and its' children again
|
||||
if (this.addedSet.has(n) || this.movedSet.has(n)) return;
|
||||
|
||||
if (this.mirror.hasNode(n)) {
|
||||
if (isIgnored(n, this.mirror)) {
|
||||
return;
|
||||
|
||||
@@ -30,6 +30,12 @@ const suites: Array<
|
||||
eval: 'window.workload()',
|
||||
times: 10,
|
||||
},
|
||||
{
|
||||
title: 'create 1000 DOM nodes and append into its previous looped node',
|
||||
html: 'benchmark-dom-mutation-multiple-descendant-add.html',
|
||||
eval: 'window.workload()',
|
||||
times: 5,
|
||||
},
|
||||
];
|
||||
|
||||
function avg(v: number[]): number {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<body></body>
|
||||
<script>
|
||||
function addMultiNodes() {
|
||||
const total = 1000;
|
||||
let parent = document.body;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const el = document.createElement('div');
|
||||
el.textContent = `el-${i + 1}`;
|
||||
parent.append(el);
|
||||
parent = el;
|
||||
}
|
||||
}
|
||||
window.workload = () => {
|
||||
addMultiNodes();
|
||||
};
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user