diff --git a/perf/benchmarks/normalize-document-twice/index.js b/perf/benchmarks/normalize-document-twice/index.js new file mode 100644 index 000000000..4341b989e --- /dev/null +++ b/perf/benchmarks/normalize-document-twice/index.js @@ -0,0 +1,19 @@ + +module.exports = { + run(state) { + const selection = state.selection.merge({ + anchorKey: '_cursor_', + anchorOffset: 0, + focusKey: '_cursor_', + focusOffset: 0 + }) + + return state + .transform({ normalized: false }).normalize().apply() + .transform() + // Make a fast, dummy change + .moveTo(selection).insertText('inserted text') + // We want to compare the speed of that second normalize (optimized through memoization, or other means) + .normalize().apply() + } +} diff --git a/perf/benchmarks/normalize-document-twice/input.yaml b/perf/benchmarks/normalize-document-twice/input.yaml new file mode 100644 index 000000000..3026b5dd2 --- /dev/null +++ b/perf/benchmarks/normalize-document-twice/input.yaml @@ -0,0 +1,120 @@ +nodes: + # Same than normalize-document-normal, but concatened 3 times +- kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: 'This is editable ' + - text: 'rich' + marks: + - type: bold + - text: ' text, ' + - text: 'much' + marks: + - type: italic + - text: ' better than a ' + - text: '