1package quantile 2 3import ( 4 "testing" 5) 6 7func BenchmarkInsertTargeted(b *testing.B) { 8 b.ReportAllocs() 9 10 s := NewTargeted(Targets) 11 b.ResetTimer() 12 for i := float64(0); i < float64(b.N); i++ { 13 s.Insert(i) 14 } 15} 16 17func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) { 18 s := NewTargeted(TargetsSmallEpsilon) 19 b.ResetTimer() 20 for i := float64(0); i < float64(b.N); i++ { 21 s.Insert(i) 22 } 23} 24 25func BenchmarkInsertBiased(b *testing.B) { 26 s := NewLowBiased(0.01) 27 b.ResetTimer() 28 for i := float64(0); i < float64(b.N); i++ { 29 s.Insert(i) 30 } 31} 32 33func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) { 34 s := NewLowBiased(0.0001) 35 b.ResetTimer() 36 for i := float64(0); i < float64(b.N); i++ { 37 s.Insert(i) 38 } 39} 40 41func BenchmarkQuery(b *testing.B) { 42 s := NewTargeted(Targets) 43 for i := float64(0); i < 1e6; i++ { 44 s.Insert(i) 45 } 46 b.ResetTimer() 47 n := float64(b.N) 48 for i := float64(0); i < n; i++ { 49 s.Query(i / n) 50 } 51} 52 53func BenchmarkQuerySmallEpsilon(b *testing.B) { 54 s := NewTargeted(TargetsSmallEpsilon) 55 for i := float64(0); i < 1e6; i++ { 56 s.Insert(i) 57 } 58 b.ResetTimer() 59 n := float64(b.N) 60 for i := float64(0); i < n; i++ { 61 s.Query(i / n) 62 } 63} 64