From 0435984da264d51b8f9cc33f4c29f9fc388acc0d Mon Sep 17 00:00:00 2001 From: JonasBa Date: Fri, 24 May 2024 13:39:12 -0400 Subject: [PATCH] perf(mutation): add deep recursive test --- packages/rrweb/package.json | 2 +- .../rrweb/test/benchmark/dom-mutation.test.ts | 58 ++++++++++--------- .../benchmark-dom-mutation-deep-nested.html | 35 +++++++++++ 3 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 packages/rrweb/test/html/benchmark-dom-mutation-deep-nested.html diff --git a/packages/rrweb/package.json b/packages/rrweb/package.json index 9c195b603f..c109413fbc 100644 --- a/packages/rrweb/package.json +++ b/packages/rrweb/package.json @@ -22,7 +22,7 @@ "check-types": "tsc -noEmit", "prepublish": "npm run typings && npm run bundle", "lint": "yarn eslint src", - "benchmark": "jest test/benchmark" + "benchmark": "jest test/benchmark/dom-mutation" }, "type": "module", "repository": { diff --git a/packages/rrweb/test/benchmark/dom-mutation.test.ts b/packages/rrweb/test/benchmark/dom-mutation.test.ts index a4124c3f98..5e62734588 100644 --- a/packages/rrweb/test/benchmark/dom-mutation.test.ts +++ b/packages/rrweb/test/benchmark/dom-mutation.test.ts @@ -19,35 +19,41 @@ const suites: Array< // times: 10, // }, { - title: 'create 1000x10 DOM nodes', - html: 'benchmark-dom-mutation.html', - eval: 'window.workload()', - times: 10, - }, - { - title: 'create 1000x10x2 DOM nodes and remove a bunch of them', - html: 'benchmark-dom-mutation-add-and-remove.html', - 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, - }, - { - title: 'create 10000 DOM nodes and move it to new container', - html: 'benchmark-dom-mutation-add-and-move.html', - eval: 'window.workload()', - times: 5, - }, - { - title: 'modify attributes on 10000 DOM nodes', - html: 'benchmark-dom-mutation-attributes.html', + title: 'create 1000x 1 DOM nodes with deeply nested children', + html: 'benchmark-dom-mutation-deep-nested.html', eval: 'window.workload()', times: 10, }, + // { + // title: 'create 1000x10 DOM nodes', + // html: 'benchmark-dom-mutation.html', + // eval: 'window.workload()', + // times: 10, + // }, + // { + // title: 'create 1000x10x2 DOM nodes and remove a bunch of them', + // html: 'benchmark-dom-mutation-add-and-remove.html', + // 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, + // }, + // { + // title: 'create 10000 DOM nodes and move it to new container', + // html: 'benchmark-dom-mutation-add-and-move.html', + // eval: 'window.workload()', + // times: 5, + // }, + // { + // title: 'modify attributes on 10000 DOM nodes', + // html: 'benchmark-dom-mutation-attributes.html', + // eval: 'window.workload()', + // times: 10, + // }, ]; function avg(v: number[]): number { diff --git a/packages/rrweb/test/html/benchmark-dom-mutation-deep-nested.html b/packages/rrweb/test/html/benchmark-dom-mutation-deep-nested.html new file mode 100644 index 0000000000..d7d8d94008 --- /dev/null +++ b/packages/rrweb/test/html/benchmark-dom-mutation-deep-nested.html @@ -0,0 +1,35 @@ + + + +