mirror of
https://github.com/yjs/yjs.git
synced 2025-12-29 00:25:01 +01:00
prelim refactor commit
This commit is contained in:
@@ -7,8 +7,9 @@ import * as array from './y-array.tests.js'
|
||||
import * as map from './y-map.tests.js'
|
||||
import * as text from './y-text.tests.js'
|
||||
import * as xml from './y-xml.tests.js'
|
||||
import * as perf from './perf.js'
|
||||
|
||||
if (isBrowser) {
|
||||
log.createVConsole(document.body)
|
||||
}
|
||||
runTests({ deleteStore, map, array, text, xml })
|
||||
runTests({ deleteStore, map, array, text, xml, perf })
|
||||
|
||||
99
tests/perf.js
Normal file
99
tests/perf.js
Normal file
@@ -0,0 +1,99 @@
|
||||
import * as t from 'lib0/testing.js'
|
||||
|
||||
class Item {
|
||||
constructor (c) {
|
||||
this.c = c
|
||||
}
|
||||
}
|
||||
|
||||
const objectsToCreate = 10000000
|
||||
|
||||
export const testItemHoldsAll = tc => {
|
||||
const items = []
|
||||
for (let i = 0; i < objectsToCreate; i++) {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
items.push(new Item(i))
|
||||
break
|
||||
case 1:
|
||||
items.push(new Item(i + ''))
|
||||
break
|
||||
case 2:
|
||||
items.push(new Item({ x: i }))
|
||||
break
|
||||
default:
|
||||
throw new Error()
|
||||
}
|
||||
}
|
||||
const call = []
|
||||
items.forEach(item => {
|
||||
switch (item.c.constructor) {
|
||||
case Number:
|
||||
call.push(item.c + '')
|
||||
break
|
||||
case String:
|
||||
call.push(item.c)
|
||||
break
|
||||
case Object:
|
||||
call.push(item.c.x + '')
|
||||
break
|
||||
default:
|
||||
throw new Error()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
class CItem { }
|
||||
|
||||
class CItemNumber {
|
||||
constructor (i) {
|
||||
this.c = i
|
||||
}
|
||||
toString () {
|
||||
return this.c + ''
|
||||
}
|
||||
}
|
||||
|
||||
class CItemString {
|
||||
constructor (s) {
|
||||
this.c = s
|
||||
}
|
||||
toString () {
|
||||
return this.c
|
||||
}
|
||||
}
|
||||
|
||||
class CItemObject {
|
||||
constructor (o) {
|
||||
this.c = o
|
||||
}
|
||||
toString () {
|
||||
return this.c.x
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
export const testDifferentItems = tc => {
|
||||
const items = []
|
||||
for (let i = 0; i < objectsToCreate; i++) {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
items.push(new CItemNumber(i))
|
||||
break
|
||||
case 1:
|
||||
items.push(new CItemString(i + ''))
|
||||
break
|
||||
case 2:
|
||||
items.push(new CItemObject({ x: i }))
|
||||
break
|
||||
default:
|
||||
throw new Error()
|
||||
}
|
||||
}
|
||||
const call = []
|
||||
items.forEach(item => {
|
||||
call.push(item.toString())
|
||||
})
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user