(b *testing.B)
| 164 | } |
| 165 | |
| 166 | func 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 | |
| 211 | func BenchmarkQueryDateRange(b *testing.B) { |
| 212 | tmpIndexPath := createTmpIndexPath(b) |
nothing calls this directly
no test coverage detected
searching dependent graphs…