Improve D&D registry normalization efficiency
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -60,6 +61,23 @@ func TestNormalizePreparesOnlyExactDuplicatesAndRetainsSameNameAndNestedPlaces(t
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkExactDuplicateGroupsManyDistinct(b *testing.B) {
|
||||
records := make([]normalizedRecord, 1_000)
|
||||
for index := range records {
|
||||
records[index] = normalizedRecord{location: dnd.Location{
|
||||
Name: "Location " + strconv.Itoa(index),
|
||||
SourceRefs: []source.SourceRef{{SourceID: "session", StartUnitID: index + 1, EndUnitID: index + 1}},
|
||||
}}
|
||||
}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for iteration := 0; iteration < b.N; iteration++ {
|
||||
if groups := exactDuplicateGroups(records); len(groups) != len(records) {
|
||||
b.Fatalf("group count = %d, want %d", len(groups), len(records))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeAppliesSafeAliasGroupAndUsesContextualInputs(t *testing.T) {
|
||||
client := &recordingLocationNormalizerClient{response: `{"duplicate_groups":[{"members":["candidate-000001","candidate-000002"],"canonical":"candidate-000002"}]}`}
|
||||
doc := semanticDocument()
|
||||
|
||||
Reference in New Issue
Block a user