Disruptor.Collections.Histogram.AddObservation C# (CSharp) Method

AddObservation() public method

public AddObservation ( long value ) : bool
value long
return bool
        public bool AddObservation(long value)
        {
            int low = 0;
            int high = _upperBounds.Length - 1;

            while (low < high)
            {
                int mid = low + ((high - low) >> 1);
                if (_upperBounds[mid] < value)
                {
                    low = mid + 1;
                }
                else
                {
                    high = mid;
                }
            }

            if (value <= _upperBounds[high])
            {
                _counts[high]++;
                TrackRange(value);

                return true;
            }

            return false;
        }

Usage Example

Exemplo n.º 1
0
        public void ShouldCorrectMeanForSkewInTopAndBottomPopulatedIntervals()
        {
            var intervals = new long[]{ 100, 110, 120, 130, 140, 150, 1000, 10000 };
            var histogram = new Histogram(intervals);

            for (long i = 100; i < 152; i++)
            {
                histogram.AddObservation(i);
            }

            Assert.AreEqual(125.02d, histogram.Mean);
        }
All Usage Examples Of Disruptor.Collections.Histogram::AddObservation