MCPcopy Index your code
hub / github.com/blevesearch/bleve / BenchmarkQueryDateRange

Function BenchmarkQueryDateRange

query_bench_test.go:211–261  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

209}
210
211func BenchmarkQueryDateRange(b *testing.B) {
212 tmpIndexPath := createTmpIndexPath(b)
213 defer cleanupTmpIndexPath(b, tmpIndexPath)
214
215 fm := mapping.NewDateTimeFieldMapping()
216 dmap := mapping.NewDocumentMapping()
217 dmap.AddFieldMappingsAt("date", fm)
218 imap := mapping.NewIndexMapping()
219 imap.DefaultMapping = dmap
220
221 idx, err := New(tmpIndexPath, imap)
222 if err != nil {
223 b.Fatal(err)
224 }
225
226 defer func() {
227 err = idx.Close()
228 if err != nil {
229 b.Fatal(err)
230 }
231 }()
232
233 members := []string{
234 "2022-11-16T18:45:45Z",
235 "2022-11-17T18:45:45Z",
236 "2022-11-18T18:45:45Z",
237 "2022-11-19T18:45:45Z",
238 "2022-11-20T18:45:45Z",
239 }
240 for i := 0; i < 100; i++ {
241 if err = idx.Index(strconv.Itoa(i),
242 map[string]interface{}{"date": members[i%len(members)]}); err != nil {
243 b.Fatal(err)
244 }
245 }
246
247 b.ReportAllocs()
248 b.ResetTimer()
249
250 inclusive := true
251 for i := 0; i < b.N; i++ {
252 start, _ := time.Parse("2006-01-02T15:04:05Z", members[i%(len(members)-2)])
253 end, _ := time.Parse("2006-01-02T15:04:05Z", members[(i+2)%(len(members)-2)])
254 q := NewDateRangeInclusiveQuery(start, end, &inclusive, &inclusive)
255 q.SetField("date")
256 req := NewSearchRequest(q)
257 if _, err = idx.Search(req); err != nil {
258 b.Fatal(err)
259 }
260 }
261}
262
263func BenchmarkQueryGeoDistance(b *testing.B) {
264 tmpIndexPath := createTmpIndexPath(b)

Callers

nothing calls this directly

Calls 14

AddFieldMappingsAtMethod · 0.95
NewDateTimeFieldMappingFunction · 0.92
NewDocumentMappingFunction · 0.92
NewIndexMappingFunction · 0.92
createTmpIndexPathFunction · 0.85
cleanupTmpIndexPathFunction · 0.85
NewSearchRequestFunction · 0.85
NewFunction · 0.70
CloseMethod · 0.65
IndexMethod · 0.65
ParseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…