Skip to content

Commit

Permalink
benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Jan 11, 2023
1 parent 6a81848 commit 1b9e8be
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func BenchmarkUnionImmutable(b *testing.B) {
}
}

func BenchmarkUnionNonImmutable(b *testing.B) {
func BenchmarkUnionMutable(b *testing.B) {
for n := 10; n <= 100_000; n *= 10 {
this100_000 := interval.NewTree(generateIvals(100_000)...)
tree := interval.NewTree(generateIvals(n)...)
Expand Down Expand Up @@ -186,3 +186,48 @@ func BenchmarkSupersets(b *testing.B) {
})
}
}

func BenchmarkSize(b *testing.B) {
for n := 100; n <= 1_000_000; n *= 10 {
ivals := generateIvals(n)
tree := interval.NewTree(ivals...)
name := "In" + intMap[n]

b.Run(name, func(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = tree.Size()
}
})
}
}

func BenchmarkMin(b *testing.B) {
for n := 100; n <= 1_000_000; n *= 10 {
ivals := generateIvals(n)
tree := interval.NewTree(ivals...)
name := "In" + intMap[n]

b.Run(name, func(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = tree.Min()
}
})
}
}

func BenchmarkMax(b *testing.B) {
for n := 100; n <= 1_000_000; n *= 10 {
ivals := generateIvals(n)
tree := interval.NewTree(ivals...)
name := "In" + intMap[n]

b.Run(name, func(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = tree.Max()
}
})
}
}

0 comments on commit 1b9e8be

Please sign in to comment.