Merge "search: add query and describe benchmarks"

This commit is contained in:
Mathieu Lonjaret 2016-08-24 23:21:15 +00:00 committed by Gerrit Code Review
commit 55a0748c37
1 changed files with 42 additions and 0 deletions

View File

@ -1468,3 +1468,45 @@ func BenchmarkQueryRecentPermanodes(b *testing.B) {
}
})
}
func BenchmarkQueryPermanodes(b *testing.B) {
benchmarkQueryPermanodes(b, false)
}
func BenchmarkQueryDescribePermanodes(b *testing.B) {
benchmarkQueryPermanodes(b, true)
}
func benchmarkQueryPermanodes(b *testing.B, describe bool) {
b.ReportAllocs()
testQueryTypes(b, corpusTypeOnly, func(qt *queryTest) {
id := qt.id
for i := 0; i < 1000; i++ {
pn := id.NewPlannedPermanode(fmt.Sprint(i))
id.SetAttribute(pn, "foo", fmt.Sprint(i))
}
req := &SearchQuery{
Constraint: &Constraint{
Permanode: &PermanodeConstraint{},
},
}
if describe {
req.Describe = &DescribeRequest{}
}
h := qt.Handler()
b.ResetTimer()
for i := 0; i < b.N; i++ {
if describe {
*req.Describe = DescribeRequest{}
}
_, err := h.Query(req)
if err != nil {
qt.t.Fatal(err)
}
}
})
}