MCPcopy
hub / github.com/perkeep/perkeep / BenchmarkQueryPermanodeLocation

Function BenchmarkQueryPermanodeLocation

pkg/search/query_test.go:2029–2093  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

2027}
2028
2029func BenchmarkQueryPermanodeLocation(b *testing.B) {
2030 b.ReportAllocs()
2031 testQueryTypes(b, corpusTypeOnly, func(qt *queryTest) {
2032 id := qt.id
2033
2034 // Upload a basic image
2035 srcRoot, err := osutil.PkSourceRoot()
2036 if err != nil {
2037 panic(fmt.Sprintf("source root folder not found: %v", err))
2038 }
2039 uploadFile := func(file string, modTime time.Time) blob.Ref {
2040 fileName := filepath.Join(srcRoot, "pkg", "search", "testdata", file)
2041 contents, err := os.ReadFile(fileName)
2042 if err != nil {
2043 panic(err)
2044 }
2045 br, _ := id.UploadFile(file, string(contents), modTime)
2046 return br
2047 }
2048 fileRef := uploadFile("dude-gps.jpg", time.Time{})
2049
2050 var n int
2051 newPn := func() blob.Ref {
2052 n++
2053 return id.NewPlannedPermanode(fmt.Sprint(n))
2054 }
2055
2056 pn := id.NewPlannedPermanode("photo")
2057 id.SetAttribute(pn, "camliContent", fileRef.String())
2058
2059 for i := 0; i < 5; i++ {
2060 pn := newPn()
2061 id.SetAttribute(pn, "camliNodeType", "foursquare.com:venue")
2062 id.SetAttribute(pn, "latitude", fmt.Sprint(50-i))
2063 id.SetAttribute(pn, "longitude", fmt.Sprint(i))
2064 for j := 0; j < 5; j++ {
2065 qn := newPn()
2066 id.SetAttribute(qn, "camliNodeType", "foursquare.com:checkin")
2067 id.SetAttribute(qn, "foursquareVenuePermanode", pn.String())
2068 }
2069 }
2070 for i := 0; i < 10; i++ {
2071 pn := newPn()
2072 id.SetAttribute(pn, "foo", fmt.Sprint(i))
2073 }
2074
2075 req := &SearchQuery{
2076 Constraint: &Constraint{
2077 Permanode: &PermanodeConstraint{
2078 Location: &LocationConstraint{Any: true},
2079 },
2080 },
2081 }
2082
2083 h := qt.Handler()
2084 b.ResetTimer()
2085
2086 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 10

PkSourceRootFunction · 0.92
testQueryTypesFunction · 0.85
NewPlannedPermanodeMethod · 0.80
SetAttributeMethod · 0.80
HandlerMethod · 0.80
FatalMethod · 0.80
QueryMethod · 0.65
uploadFileFunction · 0.50
UploadFileMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected