| 1 | package irelate |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/brentp/bix" |
| 7 | "github.com/brentp/irelate/interfaces" |
| 8 | ) |
| 9 | |
| 10 | func benchmarkStreams(nStreams int, b *testing.B) { |
| 11 | |
| 12 | for n := 0; n < b.N; n++ { |
| 13 | streams := make([]interfaces.RelatableIterator, 0) |
| 14 | f := "data/test.bed.gz" |
| 15 | |
| 16 | for i := 0; i < nStreams; i++ { |
| 17 | s, e := bix.New(f) |
| 18 | if e != nil { |
| 19 | panic(e) |
| 20 | } |
| 21 | q, e := s.Query(nil) |
| 22 | streams = append(streams, q) |
| 23 | } |
| 24 | |
| 25 | //for a := range IRelate(CheckRelatedByOverlap, 0, Less, streams...) { |
| 26 | iter := IRelate(CheckOverlapPrefix, 0, LessPrefix, streams...) |
| 27 | for { |
| 28 | a, err := iter.Next() |
| 29 | if err != nil { |
| 30 | break |
| 31 | } |
| 32 | a.Start() |
| 33 | } |
| 34 | for _, s := range streams { |
| 35 | s.Close() |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func Benchmark2Streams(b *testing.B) { benchmarkStreams(2, b) } |
| 42 | func Benchmark3Streams(b *testing.B) { benchmarkStreams(3, b) } |