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()
|
|
|
|
|
2014-06-23 21:48:50 +04:00
|
|
|
s := NewTargeted(0.01, 0.5, 0.9, 0.99)
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) {
|
|
|
|
s := NewTargeted(0.01, 0.5, 0.9, 0.99)
|
|
|
|
s.SetEpsilon(0.0001)
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertBiased(b *testing.B) {
|
|
|
|
s := NewBiased()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) {
|
|
|
|
s := NewBiased()
|
|
|
|
s.SetEpsilon(0.0001)
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := float64(0); i < float64(b.N); i++ {
|
|
|
|
s.Insert(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQuery(b *testing.B) {
|
|
|
|
s := NewTargeted(0.01, 0.5, 0.9, 0.99)
|
|
|
|
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) {
|
|
|
|
s := NewTargeted(0.01, 0.5, 0.9, 0.99)
|
|
|
|
s.SetEpsilon(0.0001)
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|