Benchmark what a bound draw costs
This commit is contained in:
@@ -57,6 +57,31 @@ func BenchmarkRepeat(b *testing.B) {
|
|||||||
benchPath(b, dir, "many")
|
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.
|
// BenchmarkNew measures load+compile+validate of the whole shipped tree.
|
||||||
func BenchmarkNew(b *testing.B) {
|
func BenchmarkNew(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
|
|||||||
Reference in New Issue
Block a user