improve mem usage by conditional execution of the integration part (step throught the integration if there are conflicting items)

This commit is contained in:
Kevin Jahns
2020-06-09 16:34:07 +02:00
parent 7fb63de8fc
commit 6b0154f046
5 changed files with 129 additions and 96 deletions

View File

@@ -205,29 +205,38 @@ export const testFormattingRemovedInMidText = tc => {
t.assert(Y.getTypeChildren(text0).length === 3)
}
const tryGc = () => {
if (typeof global !== 'undefined' && global.gc) {
global.gc()
}
}
/**
* @param {t.TestCase} tc
*/
export const testLargeFragmentedDocument = tc => {
const itemsToInsert = 1000000
const itemsToInsert = 2000000
let update = /** @type {any} */ (null)
;(() => {
const doc1 = new Y.Doc()
const text0 = doc1.getText('txt')
t.measureTime(`time to insert ${itemsToInsert}`, () => {
tryGc()
t.measureTime(`time to insert ${itemsToInsert} items`, () => {
doc1.transact(() => {
for (let i = 0; i < itemsToInsert; i++) {
text0.insert(0, '0')
}
})
})
t.measureTime('time to encode', () => {
tryGc()
t.measureTime('time to encode document', () => {
update = Y.encodeStateAsUpdate(doc1)
})
})()
;(() => {
const doc2 = new Y.Doc()
t.measureTime('time to apply', () => {
tryGc()
t.measureTime(`time to apply ${itemsToInsert} updates`, () => {
Y.applyUpdate(doc2, update)
})
})()