diff --git a/benchmark/compare.js b/benchmark/compare.js index 286938aee..44a4fdea6 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -22,6 +22,8 @@ baseline.forEach((suite, i) => { suite.benchmarks.forEach((base, j) => { const comp = comparison[i].benchmarks[j] + if (!comp) return + const b = base.iterations / base.elapsed * 100 const c = comp.iterations / comp.elapsed * 100 const threshold = b * THRESHOLD diff --git a/benchmark/fixtures/models/get-path/index.js b/benchmark/fixtures/models/get-path/index.js new file mode 100644 index 000000000..9f195e453 --- /dev/null +++ b/benchmark/fixtures/models/get-path/index.js @@ -0,0 +1,17 @@ + +import { __clear } from '../../../../lib/utils/memoize' + +export default function ({ state, text }) { + state.document.getPath(text.key) +} + +export function before(state) { + const text = state.document.getLastText() + __clear() + return { state, text } +} + +export function after() { + __clear() +} + diff --git a/benchmark/fixtures/regular/normal/input.yaml b/benchmark/fixtures/models/get-path/input.yaml similarity index 100% rename from benchmark/fixtures/regular/normal/input.yaml rename to benchmark/fixtures/models/get-path/input.yaml diff --git a/benchmark/fixtures/models/get-ranges/index.js b/benchmark/fixtures/models/get-ranges/index.js new file mode 100644 index 000000000..4348237b0 --- /dev/null +++ b/benchmark/fixtures/models/get-ranges/index.js @@ -0,0 +1,17 @@ + +import { __clear } from '../../../../lib/utils/memoize' + +export default function (text) { + text.getRanges() +} + +export function before(state) { + const text = state.document.getFirstText() + __clear() + return text +} + +export function after() { + __clear() +} + diff --git a/benchmark/fixtures/models/get-ranges/input.yaml b/benchmark/fixtures/models/get-ranges/input.yaml new file mode 100644 index 000000000..4e8716ff3 --- /dev/null +++ b/benchmark/fixtures/models/get-ranges/input.yaml @@ -0,0 +1,19 @@ +nodes: +- 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: '