mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Improve performance of simple reflist merges
When merging reflists with ignoreConflicting set to true and overrideMatching set to false, the individual ref components are never examined, but the refs are still split anyway. Avoiding the split when we never use the components brings a massive speedup: on my system, the included benchmark goes from ~1500 us/it to ~180 us/it. Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
committed by
André Roth
parent
8ab8398c50
commit
5636a9990b
@@ -0,0 +1,30 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkReflistSimpleMerge(b *testing.B) {
|
||||
const count = 4096
|
||||
|
||||
l := NewPackageRefList()
|
||||
r := NewPackageRefList()
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
if i%2 == 0 {
|
||||
l.Refs = append(l.Refs, []byte(fmt.Sprintf("Pamd64 pkg%d %d", i, i)))
|
||||
} else {
|
||||
r.Refs = append(r.Refs, []byte(fmt.Sprintf("Pamd64 pkg%d %d", i, i)))
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(l)
|
||||
sort.Sort(r)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
l.Merge(r, false, true)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user