@ -85,13 +85,13 @@ func TestExpDecaySample10(t *testing.T) {
for i := 0 ; i < 10 ; i ++ {
for i := 0 ; i < 10 ; i ++ {
s . Update ( int64 ( i ) )
s . Update ( int64 ( i ) )
}
}
if size := s . Count ( ) ; 10 != size {
if size := s . Count ( ) ; size != 10 {
t . Errorf ( "s.Count(): 10 != %v\n" , size )
t . Errorf ( "s.Count(): 10 != %v\n" , size )
}
}
if size := s . Size ( ) ; 10 != size {
if size := s . Size ( ) ; size != 10 {
t . Errorf ( "s.Size(): 10 != %v\n" , size )
t . Errorf ( "s.Size(): 10 != %v\n" , size )
}
}
if l := len ( s . Values ( ) ) ; 10 != l {
if l := len ( s . Values ( ) ) ; l != 10 {
t . Errorf ( "len(s.Values()): 10 != %v\n" , l )
t . Errorf ( "len(s.Values()): 10 != %v\n" , l )
}
}
for _ , v := range s . Values ( ) {
for _ , v := range s . Values ( ) {
@ -107,13 +107,13 @@ func TestExpDecaySample100(t *testing.T) {
for i := 0 ; i < 100 ; i ++ {
for i := 0 ; i < 100 ; i ++ {
s . Update ( int64 ( i ) )
s . Update ( int64 ( i ) )
}
}
if size := s . Count ( ) ; 100 != size {
if size := s . Count ( ) ; size != 100 {
t . Errorf ( "s.Count(): 100 != %v\n" , size )
t . Errorf ( "s.Count(): 100 != %v\n" , size )
}
}
if size := s . Size ( ) ; 100 != size {
if size := s . Size ( ) ; size != 100 {
t . Errorf ( "s.Size(): 100 != %v\n" , size )
t . Errorf ( "s.Size(): 100 != %v\n" , size )
}
}
if l := len ( s . Values ( ) ) ; 100 != l {
if l := len ( s . Values ( ) ) ; l != 100 {
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
}
}
for _ , v := range s . Values ( ) {
for _ , v := range s . Values ( ) {
@ -129,13 +129,13 @@ func TestExpDecaySample1000(t *testing.T) {
for i := 0 ; i < 1000 ; i ++ {
for i := 0 ; i < 1000 ; i ++ {
s . Update ( int64 ( i ) )
s . Update ( int64 ( i ) )
}
}
if size := s . Count ( ) ; 1000 != size {
if size := s . Count ( ) ; size != 1000 {
t . Errorf ( "s.Count(): 1000 != %v\n" , size )
t . Errorf ( "s.Count(): 1000 != %v\n" , size )
}
}
if size := s . Size ( ) ; 100 != size {
if size := s . Size ( ) ; size != 100 {
t . Errorf ( "s.Size(): 100 != %v\n" , size )
t . Errorf ( "s.Size(): 100 != %v\n" , size )
}
}
if l := len ( s . Values ( ) ) ; 100 != l {
if l := len ( s . Values ( ) ) ; l != 100 {
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
}
}
for _ , v := range s . Values ( ) {
for _ , v := range s . Values ( ) {
@ -209,13 +209,13 @@ func TestUniformSample(t *testing.T) {
for i := 0 ; i < 1000 ; i ++ {
for i := 0 ; i < 1000 ; i ++ {
s . Update ( int64 ( i ) )
s . Update ( int64 ( i ) )
}
}
if size := s . Count ( ) ; 1000 != size {
if size := s . Count ( ) ; size != 1000 {
t . Errorf ( "s.Count(): 1000 != %v\n" , size )
t . Errorf ( "s.Count(): 1000 != %v\n" , size )
}
}
if size := s . Size ( ) ; 100 != size {
if size := s . Size ( ) ; size != 100 {
t . Errorf ( "s.Size(): 100 != %v\n" , size )
t . Errorf ( "s.Size(): 100 != %v\n" , size )
}
}
if l := len ( s . Values ( ) ) ; 100 != l {
if l := len ( s . Values ( ) ) ; l != 100 {
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
t . Errorf ( "len(s.Values()): 100 != %v\n" , l )
}
}
for _ , v := range s . Values ( ) {
for _ , v := range s . Values ( ) {
@ -277,54 +277,54 @@ func benchmarkSample(b *testing.B, s Sample) {
}
}
func testExpDecaySampleStatistics ( t * testing . T , s Sample ) {
func testExpDecaySampleStatistics ( t * testing . T , s Sample ) {
if count := s . Count ( ) ; 10000 != count {
if count := s . Count ( ) ; count != 10000 {
t . Errorf ( "s.Count(): 10000 != %v\n" , count )
t . Errorf ( "s.Count(): 10000 != %v\n" , count )
}
}
if min := s . Min ( ) ; 107 != min {
if min := s . Min ( ) ; min != 107 {
t . Errorf ( "s.Min(): 107 != %v\n" , min )
t . Errorf ( "s.Min(): 107 != %v\n" , min )
}
}
if max := s . Max ( ) ; 10000 != max {
if max := s . Max ( ) ; max != 10000 {
t . Errorf ( "s.Max(): 10000 != %v\n" , max )
t . Errorf ( "s.Max(): 10000 != %v\n" , max )
}
}
if mean := s . Mean ( ) ; 4965.98 != mean {
if mean := s . Mean ( ) ; mean != 4965.98 {
t . Errorf ( "s.Mean(): 4965.98 != %v\n" , mean )
t . Errorf ( "s.Mean(): 4965.98 != %v\n" , mean )
}
}
if stdDev := s . StdDev ( ) ; 2959.825156930727 != stdDev {
if stdDev := s . StdDev ( ) ; stdDev != 2959.825156930727 {
t . Errorf ( "s.StdDev(): 2959.825156930727 != %v\n" , stdDev )
t . Errorf ( "s.StdDev(): 2959.825156930727 != %v\n" , stdDev )
}
}
ps := s . Percentiles ( [ ] float64 { 0.5 , 0.75 , 0.99 } )
ps := s . Percentiles ( [ ] float64 { 0.5 , 0.75 , 0.99 } )
if 4615 != ps [ 0 ] {
if ps [ 0 ] != 4615 {
t . Errorf ( "median: 4615 != %v\n" , ps [ 0 ] )
t . Errorf ( "median: 4615 != %v\n" , ps [ 0 ] )
}
}
if 7672 != ps [ 1 ] {
if ps [ 1 ] != 7672 {
t . Errorf ( "75th percentile: 7672 != %v\n" , ps [ 1 ] )
t . Errorf ( "75th percentile: 7672 != %v\n" , ps [ 1 ] )
}
}
if 9998.99 != ps [ 2 ] {
if ps [ 2 ] != 9998.99 {
t . Errorf ( "99th percentile: 9998.99 != %v\n" , ps [ 2 ] )
t . Errorf ( "99th percentile: 9998.99 != %v\n" , ps [ 2 ] )
}
}
}
}
func testUniformSampleStatistics ( t * testing . T , s Sample ) {
func testUniformSampleStatistics ( t * testing . T , s Sample ) {
if count := s . Count ( ) ; 10000 != count {
if count := s . Count ( ) ; count != 10000 {
t . Errorf ( "s.Count(): 10000 != %v\n" , count )
t . Errorf ( "s.Count(): 10000 != %v\n" , count )
}
}
if min := s . Min ( ) ; 37 != min {
if min := s . Min ( ) ; min != 37 {
t . Errorf ( "s.Min(): 37 != %v\n" , min )
t . Errorf ( "s.Min(): 37 != %v\n" , min )
}
}
if max := s . Max ( ) ; 9989 != max {
if max := s . Max ( ) ; max != 9989 {
t . Errorf ( "s.Max(): 9989 != %v\n" , max )
t . Errorf ( "s.Max(): 9989 != %v\n" , max )
}
}
if mean := s . Mean ( ) ; 4748.14 != mean {
if mean := s . Mean ( ) ; mean != 4748.14 {
t . Errorf ( "s.Mean(): 4748.14 != %v\n" , mean )
t . Errorf ( "s.Mean(): 4748.14 != %v\n" , mean )
}
}
if stdDev := s . StdDev ( ) ; 2826.684117548333 != stdDev {
if stdDev := s . StdDev ( ) ; stdDev != 2826.684117548333 {
t . Errorf ( "s.StdDev(): 2826.684117548333 != %v\n" , stdDev )
t . Errorf ( "s.StdDev(): 2826.684117548333 != %v\n" , stdDev )
}
}
ps := s . Percentiles ( [ ] float64 { 0.5 , 0.75 , 0.99 } )
ps := s . Percentiles ( [ ] float64 { 0.5 , 0.75 , 0.99 } )
if 4599 != ps [ 0 ] {
if ps [ 0 ] != 4599 {
t . Errorf ( "median: 4599 != %v\n" , ps [ 0 ] )
t . Errorf ( "median: 4599 != %v\n" , ps [ 0 ] )
}
}
if 7380.5 != ps [ 1 ] {
if ps [ 1 ] != 7380.5 {
t . Errorf ( "75th percentile: 7380.5 != %v\n" , ps [ 1 ] )
t . Errorf ( "75th percentile: 7380.5 != %v\n" , ps [ 1 ] )
}
}
if math . Abs ( 9986.429999999998 - ps [ 2 ] ) > epsilonPercentile {
if math . Abs ( 9986.429999999998 - ps [ 2 ] ) > epsilonPercentile {