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

Function BenchmarkQueryNumericRange

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

Source from the content-addressed store, hash-verified

164}
165
166func BenchmarkQueryNumericRange(b *testing.B) {
167 tmpIndexPath := createTmpIndexPath(b)
168 defer cleanupTmpIndexPath(b, tmpIndexPath)
169
170 fm := mapping.NewNumericFieldMapping()
171 dmap := mapping.NewDocumentMapping()
172 dmap.AddFieldMappingsAt("number", fm)
173 imap := mapping.NewIndexMapping()
174 imap.DefaultMapping = dmap
175
176 idx, err := New(tmpIndexPath, imap)
177 if err != nil {
178 b.Fatal(err)
179 }
180
181 defer func() {
182 err = idx.Close()
183 if err != nil {
184 b.Fatal(err)
185 }
186 }()
187
188 for i := 0; i < 100; i++ {
189 if err = idx.Index(strconv.Itoa(i),
190 map[string]interface{}{"number": i}); err != nil {
191 b.Fatal(err)
192 }
193 }
194
195 b.ReportAllocs()
196 b.ResetTimer()
197
198 inclusive := true
199 for i := 0; i < b.N; i++ {
200 start := float64(i % 90)
201 end := float64((i + 10) % 90)
202 q := NewNumericRangeInclusiveQuery(&start, &end, &inclusive, &inclusive)
203 q.SetField("number")
204 req := NewSearchRequest(q)
205 if _, err = idx.Search(req); err != nil {
206 b.Fatal(err)
207 }
208 }
209}
210
211func BenchmarkQueryDateRange(b *testing.B) {
212 tmpIndexPath := createTmpIndexPath(b)

Callers

nothing calls this directly

Calls 13

AddFieldMappingsAtMethod · 0.95
NewNumericFieldMappingFunction · 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
SetFieldMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…