MCPcopy
hub / github.com/yjs/yjs / testLargeFragmentedDocument

Function testLargeFragmentedDocument

tests/y-text.tests.js:1703–1730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1701 * @param {t.TestCase} _tc
1702 */
1703export const testLargeFragmentedDocument = _tc => {
1704 const itemsToInsert = largeDocumentSize
1705 let update = /** @type {any} */ (null)
1706 ;(() => {
1707 const doc1 = new Y.Doc()
1708 const text0 = doc1.get('txt')
1709 tryGc()
1710 t.measureTime(`time to insert ${itemsToInsert} items`, () => {
1711 doc1.transact(() => {
1712 for (let i = 0; i < itemsToInsert; i++) {
1713 text0.insert(0, '0')
1714 }
1715 })
1716 })
1717 tryGc()
1718 t.measureTime('time to encode document', () => {
1719 update = Y.encodeStateAsUpdateV2(doc1)
1720 })
1721 t.describe('Document size:', update.byteLength)
1722 })()
1723 ;(() => {
1724 const doc2 = new Y.Doc()
1725 tryGc()
1726 t.measureTime(`time to apply ${itemsToInsert} updates`, () => {
1727 Y.applyUpdateV2(doc2, update)
1728 })
1729 })()
1730}
1731
1732/**
1733 * @param {t.TestCase} _tc

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
transactMethod · 0.95
insertMethod · 0.80
tryGcFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…