MCPcopy
hub / github.com/yjs/yjs / testIncrementalUpdatesPerformanceOnLargeFragmentedDocument

Function testIncrementalUpdatesPerformanceOnLargeFragmentedDocument

tests/y-text.tests.js:1735–1766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1733 * @param {t.TestCase} _tc
1734 */
1735export const testIncrementalUpdatesPerformanceOnLargeFragmentedDocument = _tc => {
1736 const itemsToInsert = largeDocumentSize
1737 const updates = /** @type {Array<Uint8Array<ArrayBuffer>>} */ ([])
1738 ;(() => {
1739 const doc1 = new Y.Doc()
1740 doc1.on('update', update => {
1741 updates.push(update)
1742 })
1743 const text0 = doc1.get('txt')
1744 tryGc()
1745 t.measureTime(`time to insert ${itemsToInsert} items`, () => {
1746 doc1.transact(() => {
1747 for (let i = 0; i < itemsToInsert; i++) {
1748 text0.insert(0, '0')
1749 }
1750 })
1751 })
1752 tryGc()
1753 })()
1754 ;(() => {
1755 t.measureTime(`time to merge ${itemsToInsert} updates (differential updates)`, () => {
1756 Y.mergeUpdates(updates)
1757 })
1758 tryGc()
1759 t.measureTime(`time to merge ${itemsToInsert} updates (ydoc updates)`, () => {
1760 const ydoc = new Y.Doc()
1761 updates.forEach(update => {
1762 Y.applyUpdate(ydoc, update)
1763 })
1764 })
1765 })()
1766}
1767
1768/**
1769 * Splitting surrogates can lead to invalid encoded documents.

Callers

nothing calls this directly

Calls 6

getMethod · 0.95
transactMethod · 0.95
pushMethod · 0.80
insertMethod · 0.80
tryGcFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…