mikejihbe/metrics — Issue #9: ExponentiallyDecayingSample is sorted wrong
Author: felixge
Created: 2011-11-16 21:03:51+00:00
State: open

The BinaryHeap used by ExponentiallyDecayingSample is sorted wrong. The highest priority item is always on top of the tree:

https://github.com/mikejihbe/metrics/blob/master/stats/exponentially_decaying_sample.js#L34

This is bad because when the sample is full, and a new value is being added, the highest priority item is removed to make room for it:

https://github.com/mikejihbe/metrics/blob/master/stats/exponentially_decaying_sample.js#L71

This probably happened because BinaryHeap#pop is poorly named. In reality it is removing the first/top element of the heap, rather than the last as the name would indicate.