removed old benchmarks and helper func

This commit is contained in:
pippellia-btc
2025-07-10 17:44:46 +02:00
parent b637e35991
commit 3cac4b98e5
2 changed files with 0 additions and 81 deletions

View File

@@ -1,7 +1,6 @@
package graph
import (
"fmt"
"reflect"
"testing"
)
@@ -50,69 +49,3 @@ func TestNewDelta(t *testing.T) {
})
}
}
func BenchmarkNewDelta(b *testing.B) {
sizes := []int{1000, 10000, 100000}
for _, size := range sizes {
b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) {
old := RandomIDs(size)
new := RandomIDs(size)
b.ResetTimer()
for range b.N {
NewDelta(3, "0", old, new)
}
})
}
}
func BenchmarkNewDeltaSets(b *testing.B) {
sizes := []int{1000, 10000, 100000}
for _, size := range sizes {
b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) {
old := RandomIDs(size)
new := RandomIDs(size)
b.ResetTimer()
for range b.N {
newDeltaSet(3, "0", old, new)
}
})
}
}
func newDeltaSet(kind int, node ID, old, new []ID) Delta {
delta := Delta{
Kind: kind,
Node: node,
}
oldMap := make(map[ID]struct{}, len(old))
newMap := make(map[ID]struct{}, len(new))
// Fill maps
for _, id := range old {
oldMap[id] = struct{}{}
}
for _, id := range new {
newMap[id] = struct{}{}
}
// Find removed and kept
for _, id := range old {
if _, found := newMap[id]; found {
delta.Keep = append(delta.Keep, id)
} else {
delta.Remove = append(delta.Remove, id)
}
}
// Find added
for _, id := range new {
if _, found := oldMap[id]; !found {
delta.Add = append(delta.Add, id)
}
}
return delta
}