Merge pull request #81 from prometheus/beorn7/versioning
Update vendoring of beorn7/perks.
This commit is contained in:
commit
3f532e73b1
|
@ -1 +1 @@
|
||||||
Imported at f15ca8fc2964cb9f291e1cf17bb1bf9a4f9e23d5 from https://github.com/beorn7/perks .
|
Imported at b965b613227fddccbfffe13eae360ed3fa822f8d from https://github.com/beorn7/perks .
|
||||||
|
|
|
@ -5,11 +5,12 @@ package quantile_test
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bmizerany/perks/quantile"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/beorn7/perks/quantile"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Example_simple() {
|
func Example_simple() {
|
||||||
|
@ -17,7 +18,11 @@ func Example_simple() {
|
||||||
go sendFloats(ch)
|
go sendFloats(ch)
|
||||||
|
|
||||||
// Compute the 50th, 90th, and 99th percentile.
|
// Compute the 50th, 90th, and 99th percentile.
|
||||||
q := quantile.NewTargeted(0.50, 0.90, 0.99)
|
q := quantile.NewTargeted(map[float64]float64{
|
||||||
|
0.50: 0.005,
|
||||||
|
0.90: 0.001,
|
||||||
|
0.99: 0.0001,
|
||||||
|
})
|
||||||
for v := range ch {
|
for v := range ch {
|
||||||
q.Insert(v)
|
q.Insert(v)
|
||||||
}
|
}
|
||||||
|
@ -28,8 +33,8 @@ func Example_simple() {
|
||||||
fmt.Println("count:", q.Count())
|
fmt.Println("count:", q.Count())
|
||||||
// Output:
|
// Output:
|
||||||
// perc50: 5
|
// perc50: 5
|
||||||
// perc90: 14
|
// perc90: 16
|
||||||
// perc99: 40
|
// perc99: 223
|
||||||
// count: 2388
|
// count: 2388
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +57,7 @@ func Example_mergeMultipleStreams() {
|
||||||
// even if we do not plan to query them all here.
|
// even if we do not plan to query them all here.
|
||||||
ch := make(chan quantile.Samples)
|
ch := make(chan quantile.Samples)
|
||||||
getDBQuerySamples(ch)
|
getDBQuerySamples(ch)
|
||||||
q := quantile.NewTargeted(0.90)
|
q := quantile.NewTargeted(map[float64]float64{0.90: 0.001})
|
||||||
for samples := range ch {
|
for samples := range ch {
|
||||||
q.Merge(samples)
|
q.Merge(samples)
|
||||||
}
|
}
|
||||||
|
@ -67,7 +72,11 @@ func Example_window() {
|
||||||
go sendStreamValues(ch)
|
go sendStreamValues(ch)
|
||||||
|
|
||||||
tick := time.NewTicker(1 * time.Minute)
|
tick := time.NewTicker(1 * time.Minute)
|
||||||
q := quantile.NewTargeted(0.90, 0.95, 0.99)
|
q := quantile.NewTargeted(map[float64]float64{
|
||||||
|
0.90: 0.001,
|
||||||
|
0.95: 0.0005,
|
||||||
|
0.99: 0.0001,
|
||||||
|
})
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case t := <-tick.C:
|
case t := <-tick.C:
|
||||||
|
|
|
@ -113,7 +113,8 @@ func TestHighBiasedQuery(t *testing.T) {
|
||||||
verifyHighPercsWithRelativeEpsilon(t, a, s)
|
verifyHighPercsWithRelativeEpsilon(t, a, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTargetedMerge(t *testing.T) {
|
// BrokenTestTargetedMerge is broken, see Merge doc comment.
|
||||||
|
func BrokenTestTargetedMerge(t *testing.T) {
|
||||||
rand.Seed(42)
|
rand.Seed(42)
|
||||||
s1 := NewTargeted(Targets)
|
s1 := NewTargeted(Targets)
|
||||||
s2 := NewTargeted(Targets)
|
s2 := NewTargeted(Targets)
|
||||||
|
@ -123,7 +124,8 @@ func TestTargetedMerge(t *testing.T) {
|
||||||
verifyPercsWithAbsoluteEpsilon(t, a, s1)
|
verifyPercsWithAbsoluteEpsilon(t, a, s1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLowBiasedMerge(t *testing.T) {
|
// BrokenTestLowBiasedMerge is broken, see Merge doc comment.
|
||||||
|
func BrokenTestLowBiasedMerge(t *testing.T) {
|
||||||
rand.Seed(42)
|
rand.Seed(42)
|
||||||
s1 := NewLowBiased(RelativeEpsilon)
|
s1 := NewLowBiased(RelativeEpsilon)
|
||||||
s2 := NewLowBiased(RelativeEpsilon)
|
s2 := NewLowBiased(RelativeEpsilon)
|
||||||
|
@ -133,7 +135,8 @@ func TestLowBiasedMerge(t *testing.T) {
|
||||||
verifyLowPercsWithRelativeEpsilon(t, a, s2)
|
verifyLowPercsWithRelativeEpsilon(t, a, s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHighBiasedMerge(t *testing.T) {
|
// BrokenTestHighBiasedMerge is broken, see Merge doc comment.
|
||||||
|
func BrokenTestHighBiasedMerge(t *testing.T) {
|
||||||
rand.Seed(42)
|
rand.Seed(42)
|
||||||
s1 := NewHighBiased(RelativeEpsilon)
|
s1 := NewHighBiased(RelativeEpsilon)
|
||||||
s2 := NewHighBiased(RelativeEpsilon)
|
s2 := NewHighBiased(RelativeEpsilon)
|
||||||
|
|
Loading…
Reference in New Issue