Benchmark what a bound draw costs

This commit is contained in:
M
2026-08-29 14:03:48 +02:00
committed by lilleman-tw
parent b8da6fdbc0
commit 644f3ed9d9
+25
View File
@@ -57,6 +57,31 @@ func BenchmarkRepeat(b *testing.B) {
benchPath(b, dir, "many")
}
// BenchmarkBound measures a format that binds a head and reads two paths from it —
// what a correlated pair costs against BenchmarkUnbound, the same output drawn from
// two independent fields.
func BenchmarkBound(b *testing.B) {
dir := tmpData(b, "addr", `{"format":"{place.postal-code} {place.locality}","place":[
{"format":"{locality}","locality":"Stockholm","postal-code":{"format":"#100 00"}},
{"format":"{locality}","locality":"Tranås","postal-code":{"format":"#5#7#3 00"}}]}`)
benchPath(b, dir, "addr")
}
func BenchmarkUnbound(b *testing.B) {
dir := tmpData(b, "addr", `{"format":"{postal-code} {locality}",
"postal-code":[{"format":"#100 00"},{"format":"#5#7#3 00"}],
"locality":["Stockholm","Tranås"]}`)
benchPath(b, dir, "addr")
}
// BenchmarkBoundDeep reads two paths through an intermediate level, the shape the
// depth question is about.
func BenchmarkBoundDeep(b *testing.B) {
dir := tmpData(b, "addr", `{"format":"{p.addr.city} {p.addr.zip}","p":[
{"format":"{addr}","addr":{"format":"{city}","city":["Stockholm","Tranås"],"zip":{"format":"#100 00"}}}]}`)
benchPath(b, dir, "addr")
}
// BenchmarkNew measures load+compile+validate of the whole shipped tree.
func BenchmarkNew(b *testing.B) {
b.ReportAllocs()