prelim refactor commit

This commit is contained in:
Kevin Jahns
2019-03-26 01:14:15 +01:00
parent 293527e62b
commit d9ab593b07
44 changed files with 2263 additions and 1914 deletions

View File

@@ -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
View 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())
})
}
*/