1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
14 type maskSuite struct{}
16 var _ = check.Suite(&maskSuite{})
18 func (s *maskSuite) TestMask(c *check.C) {
20 for i := 0; i < 1000000; i++ {
21 start := rand.Int() % 100000
22 end := rand.Int()%100000 + start
23 if start <= 9000 && end >= 8000 ||
24 start <= 8 && end >= 4 ||
28 m.Add("chr1", start, end)
30 m.Add("chr1", 1200, 3400)
31 m.Add("chr1", 5600, 7800)
32 m.Add("chr1", 5300, 7900)
33 m.Add("chr1", 9900, 9900)
39 c.Check(m.Check("chr1", 1, 1), check.Equals, true)
40 c.Check(m.Check("chr1", 4, 8), check.Equals, false)
41 c.Check(m.Check("chr1", 7800, 8000), check.Equals, true)
42 c.Check(m.Check("chr1", 8000, 9000), check.Equals, false)
43 c.Check(m.Check("chr1999", 1, 1), check.Equals, false)
46 func BenchmarkMask1000(b *testing.B) {
47 benchmarkMask(b, 1000)
50 func BenchmarkMask10000(b *testing.B) {
51 benchmarkMask(b, 10000)
54 func BenchmarkMask100000(b *testing.B) {
55 benchmarkMask(b, 100000)
58 func BenchmarkMask1000000(b *testing.B) {
59 benchmarkMask(b, 1000000)
62 func benchmarkMask(b *testing.B, size int) {
64 for i := 0; i < size; i++ {
65 start := rand.Int() % 10000000
66 end := rand.Int()%300 + start
67 m.Add("chrB", start, end)
70 for n := 0; n < b.N; n++ {
71 start := rand.Int() % 10000000
72 end := rand.Int()%300 + start
73 m.Check("chrB", start, end)