Reuse origin metadata across configuration collections

This commit is contained in:
2026-10-17 13:46:58 +00:00
parent 165cef7aec
commit a1f12f3185
6 changed files with 79 additions and 23 deletions

View File

@@ -126,6 +126,40 @@ func layeredDefinitions(count int) configurationShape {
}
}
func BenchmarkCollectionFileBackedConstruction(b *testing.B) {
for _, count := range []int{4, 16, 64} {
b.Run(fmt.Sprintf("collections_%d", count), func(b *testing.B) {
collections := make(map[string]any, count)
for index := range count {
collections[fmt.Sprintf("collection-%03d", index)] = map[string]any{
"prompts": map[string]any{
"example": map[string]any{
"messages": []any{map[string]any{"role": "user", "content_file": "body.md"}},
"output": map[string]any{"format": "text", "validation_mode": "none"},
},
},
}
}
namespace := configkit.NewFilesystem("collection benchmark", fstest.MapFS{
"body.md": {Data: []byte("Hello")},
})
main := configkit.Input{
Source: configkit.Mapping("collections", map[string]any{"collections": collections}),
Filesystem: &configkit.FilesystemContext{FS: &namespace, Root: ".", BaseDir: "."},
}
b.ReportAllocs()
for b.Loop() {
result, err := load(main, nil)
if err != nil {
b.Fatal(err)
}
constructionResult = result
}
b.ReportMetric(float64(count), "collections/op")
})
}
}
func BenchmarkConfigurationConstruction(b *testing.B) {
for _, scenario := range []struct {
name string