glob/match/segements_test.go

66 lines
1.0 KiB
Go
Raw Normal View History

2016-02-22 20:22:04 +03:00
package match
import (
"testing"
)
func BenchmarkPerfPoolSequenced(b *testing.B) {
2016-02-22 22:17:07 +03:00
pool := NewPoolSequenced(512, func() []int {
2016-02-22 20:22:04 +03:00
return make([]int, 0, 16)
})
2016-02-22 22:17:07 +03:00
b.SetParallelism(32)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
s := pool.Get()
pool.Put(s)
}
})
2016-02-22 20:22:04 +03:00
}
func BenchmarkPerfPoolSynced(b *testing.B) {
pool := NewPoolSynced(32)
2016-02-22 22:17:07 +03:00
b.SetParallelism(32)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
s := pool.Get()
pool.Put(s)
}
})
2016-02-22 20:22:04 +03:00
}
2016-02-22 22:17:07 +03:00
func BenchmarkPerfPoolNative(b *testing.B) {
pool := NewPoolNative(func() []int {
return make([]int, 0, 16)
})
b.SetParallelism(32)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
s := pool.Get()
pool.Put(s)
}
})
}
func BenchmarkPerfPoolStatic(b *testing.B) {
pool := NewPoolStatic(32, func() []int {
return make([]int, 0, 16)
})
b.SetParallelism(32)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
i, v := pool.Get()
pool.Put(i, v)
}
})
2016-02-22 20:22:04 +03:00
}
func BenchmarkPerfMake(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make([]int, 0, 32)
}
}