2014-06-23 21:48:50 +04:00
|
|
|
package quantile
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkInsertTargeted(b *testing.B) {
|
2014-12-05 15:50:14 +03:00
|
|
|
b.ReportAllocs()
|
|
|
|
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewTargeted(Targets)
|
2014-06-23 21:48:50 +04:00
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) {
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewTargeted(TargetsSmallEpsilon)
|
2014-06-23 21:48:50 +04:00
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertBiased(b *testing.B) {
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewLowBiased(0.01)
|
2014-06-23 21:48:50 +04:00
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) {
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewLowBiased(0.0001)
|
2014-06-23 21:48:50 +04:00
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQuery(b *testing.B) {
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewTargeted(Targets)
|
2014-06-23 21:48:50 +04:00
|
|
|
for i := float64(0); i < 1e6; i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
b.ResetTimer()
|
|
|
|
n := float64(b.N)
|
|
|
|
for i := float64(0); i < n; i++ {
|
|
|
|
s.Query(i / n)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQuerySmallEpsilon(b *testing.B) {
|
2015-01-20 20:27:10 +03:00
|
|
|
s := NewTargeted(TargetsSmallEpsilon)
|
2014-06-23 21:48:50 +04:00
|
|
|
for i := float64(0); i < 1e6; i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
b.ResetTimer()
|
|
|
|
n := float64(b.N)
|
|
|
|
for i := float64(0); i < n; i++ {
|
|
|
|
s.Query(i / n)
|
|
|
|
}
|
|
|
|
}
|