Codebase list golang-github-beorn7-perks / f0d0b7f
Remove Stream.Min/Max ... These are best calculated by the user as items are inserted. These can't be represented accurately in Samples. Blake Mizerany 11 years ago
2 changed file(s) with 0 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
2222 fmt.Println("perc50:", q.Query(0.50))
2323 fmt.Println("perc90:", q.Query(0.90))
2424 fmt.Println("perc99:", q.Query(0.99))
25 fmt.Println("min:", q.Min())
26 fmt.Println("max:", q.Max())
2725 fmt.Println("count:", q.Count())
2826 // Output:
2927 // perc50: 5
3028 // perc90: 14
3129 // perc99: 40
32 // min: 1
33 // max: 1545
3430 // count: 2388
3531 }
3632
111111 q []float64
112112 n float64
113113 l *list.List
114 max float64
115114 }
116115
117116 func (s *stream) Init() {
151150 var r float64
152151 e := s.l.Front()
153152 return func(v, w float64) {
154 if v > s.max {
155 s.max = v
156 }
157
158153 for ; e != nil; e = e.Next() {
159154 c := e.Value.(*Sample)
160155 if c.Value > v {
225220 }
226221 return samples
227222 }
228
229 // Min returns the minimum value observed in the stream.
230 func (s *stream) Min() float64 {
231 if e := s.l.Front(); e != nil {
232 return e.Value.(*Sample).Value
233 }
234 return math.NaN()
235 }
236
237 // Max returns the maximum value observed in the stream within the error epsilon.
238 func (s *stream) Max() float64 {
239 if s.l.Len() > 0 {
240 return s.max
241 }
242 return math.NaN()
243 }