Scan YAML framing preambles once

This commit is contained in:
2026-10-09 01:30:17 +00:00
parent ae656d8fa9
commit 3f8841f298
4 changed files with 145 additions and 64 deletions

View File

@@ -72,14 +72,14 @@ func BenchmarkPerformanceYAMLFraming(b *testing.B) {
}
for _, fixture := range fixtures {
b.Run("framing/"+fixture.name, func(b *testing.B) {
framed := frameEffectiveYAML(fixture.scope, fixture.native)
if len(framed) <= len(fixture.native) || hasYAMLDirective(fixture.native) != strings.Contains(fixture.name, "directive") {
framed, hasDirective := frameEffectiveYAML(fixture.scope, fixture.native)
if len(framed) <= len(fixture.native) || hasDirective != strings.Contains(fixture.name, "directive") {
b.Fatalf("framing fixture result has unexpected size or directive classification: native=%d framed=%d", len(fixture.native), len(framed))
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
performanceFramedBytes = frameEffectiveYAML(fixture.scope, fixture.native)
performanceFramedBytes, _ = frameEffectiveYAML(fixture.scope, fixture.native)
}
})
b.Run("aggregate/"+fixture.name, func(b *testing.B) {