mirror of https://github.com/perkeep/perkeep.git
search: add query and describe benchmarks
Change-Id: I21e0199a0209a47d2e24fc3adf1dbf08f8d3be75
This commit is contained in:
parent
555b5cfd09
commit
06036c2612
|
@ -1440,3 +1440,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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue