working on performance

This commit is contained in:
Kevin Jahns
2025-04-24 17:46:00 +02:00
parent 69786f7ee5
commit fbfe0e0eeb
3 changed files with 35 additions and 4 deletions

View File

@@ -2605,6 +2605,37 @@ const checkResult = result => {
return result
}
/**
* @param {t.TestCase} tc
*/
export const testAttributionManagerDefaultPerformance = tc => {
const N = 100000
const ydoc = new Y.Doc()
const ytext = ydoc.getText()
for (let i = 0; i < N; i++) {
if (prng.bool(tc.prng) && ytext.length > 0) {
const index = prng.int31(tc.prng, 0, ytext.length - 1)
const len = prng.int31(tc.prng, 0, math.min(ytext.length - index, 5))
ytext.delete(index, len)
} else {
const index = prng.int31(tc.prng, 0, ytext.length)
const content = prng.utf16String(tc.prng, 30)
ytext.insert(index, content)
}
}
const M = 100
t.measureTime('original toDelta perf', () => {
for (let i = 0; i < M; i++) {
ytext.toDelta()
}
})
t.measureTime('getContent(attributionManager) performance)', () => {
for (let i = 0; i < M; i++) {
ytext.getContent()
}
})
}
/**
* @param {t.TestCase} tc
*/