MCPcopy
hub / github.com/perkeep/perkeep / benchmarkQueryPermanodes

Function benchmarkQueryPermanodes

pkg/search/query_test.go:1995–2027  ·  view source on GitHub ↗
(b *testing.B, describe bool)

Source from the content-addressed store, hash-verified

1993}
1994
1995func benchmarkQueryPermanodes(b *testing.B, describe bool) {
1996 b.ReportAllocs()
1997 testQueryTypes(b, corpusTypeOnly, func(qt *queryTest) {
1998 id := qt.id
1999
2000 for i := 0; i < 1000; i++ {
2001 pn := id.NewPlannedPermanode(fmt.Sprint(i))
2002 id.SetAttribute(pn, "foo", fmt.Sprint(i))
2003 }
2004
2005 req := &SearchQuery{
2006 Constraint: &Constraint{
2007 Permanode: &PermanodeConstraint{},
2008 },
2009 }
2010 if describe {
2011 req.Describe = &DescribeRequest{}
2012 }
2013
2014 h := qt.Handler()
2015 b.ResetTimer()
2016
2017 for i := 0; i < b.N; i++ {
2018 if describe {
2019 *req.Describe = DescribeRequest{}
2020 }
2021 _, err := h.Query(ctxbg, req)
2022 if err != nil {
2023 qt.t.Fatal(err)
2024 }
2025 }
2026 })
2027}
2028
2029func BenchmarkQueryPermanodeLocation(b *testing.B) {
2030 b.ReportAllocs()

Callers 2

BenchmarkQueryPermanodesFunction · 0.85

Calls 6

testQueryTypesFunction · 0.85
NewPlannedPermanodeMethod · 0.80
SetAttributeMethod · 0.80
HandlerMethod · 0.80
FatalMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected