| 1733 | * @param {t.TestCase} _tc |
| 1734 | */ |
| 1735 | export 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. |