File: bench_test.go

package info (click to toggle)
golang-github-brentp-irelate 0.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 12,624 kB
  • sloc: makefile: 10; python: 5; sh: 4
file content (42 lines) | stat: -rw-r--r-- 823 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package irelate

import (
	"testing"

	"github.com/brentp/bix"
	"github.com/brentp/irelate/interfaces"
)

func benchmarkStreams(nStreams int, b *testing.B) {

	for n := 0; n < b.N; n++ {
		streams := make([]interfaces.RelatableIterator, 0)
		f := "data/test.bed.gz"

		for i := 0; i < nStreams; i++ {
			s, e := bix.New(f)
			if e != nil {
				panic(e)
			}
			q, e := s.Query(nil)
			streams = append(streams, q)
		}

		//for a := range IRelate(CheckRelatedByOverlap, 0, Less, streams...) {
		iter := IRelate(CheckOverlapPrefix, 0, LessPrefix, streams...)
		for {
			a, err := iter.Next()
			if err != nil {
				break
			}
			a.Start()
		}
		for _, s := range streams {
			s.Close()
		}

	}
}

func Benchmark2Streams(b *testing.B) { benchmarkStreams(2, b) }
func Benchmark3Streams(b *testing.B) { benchmarkStreams(3, b) }