Commit 892232da authored by Kirill Smelkov's avatar Kirill Smelkov

X δbtail: tests: Use Clone in verify_rebuild

	$ time go test -failfast -short -run 'ΔBTail/rebuild' >x

before:

	real    1m44,975s
	user    2m18,809s
	sys     0m12,384s

after:

	real    1m15,669s
	user    1m31,340s
	sys     0m10,171s
parent f0453574
...@@ -449,6 +449,46 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail { ...@@ -449,6 +449,46 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
} }
} }
// xverifyΔBTail_rebuild needs ΔBTree.clone because otherwise it is too slow to run that test.
func (orig *ΔBtail) clone() *ΔBtail {
klon := NewΔBtail(orig.Tail(), orig.db)
// δZtail
for _, δZ := range orig.δZtail.Data() {
klon.δZtail.Append(δZ.Rev, δZ.Changev)
}
// trackIdx
for oid, t := range orig.trackIdx {
klon.trackIdx[oid] = &nodeTrack{parent: t.parent, nchild: t.nchild}
}
// trackNew
for oid, t := range orig.trackNew {
klon.trackNew[oid] = &nodeTrack{parent: t.parent, nchild: t.nchild}
}
// byRoot
for root, origΔTtail := range orig.byRoot {
klonΔTtail := &ΔTtail{}
klonΔTtail.vδT = append(klonΔTtail.vδT, origΔTtail.vδT...)
for k, v := range origΔTtail.KVAtTail {
klonΔTtail.KVAtTail[k] = v
}
for k, rev := range origΔTtail.lastRevOf {
klonΔTtail.lastRevOf[k] = rev
}
klon.byRoot[root] = klonΔTtail
}
// holeIdxByRoot
for root, origHoleIdx := range orig.holeIdxByRoot {
klonHoleIdx := treeSetKey{SetKey{}}
klonHoleIdx.Update(origHoleIdx.SetKey)
klon.holeIdxByRoot[root] = klonHoleIdx
}
return klon
}
// newΔTtail creates new empty ΔTtail object. // newΔTtail creates new empty ΔTtail object.
func newΔTtail() *ΔTtail { func newΔTtail() *ΔTtail {
return &ΔTtail{ return &ΔTtail{
......
...@@ -912,11 +912,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -912,11 +912,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t.Run(fmt.Sprintf(" →%s T%s;R", t2.tree, keys2), func(t *testing.T) { t.Run(fmt.Sprintf(" →%s T%s;R", t2.tree, keys2), func(t *testing.T) {
// XXX implement Clone and go the clone way if test starts running too slow //δbtail = NewΔBtail(t0.at, db)
//δbtail_ := δbtail.Clone() //step1()
δbtail = NewΔBtail(t0.at, db) //δbtail_ := δbtail
step1() δbtail_ := δbtail.clone()
δbtail_ := δbtail
// tracked keys1 becomes tracked keys1_2 after Update(t1->t2) // tracked keys1 becomes tracked keys1_2 after Update(t1->t2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment