Jellyfish.Commands.Metrics.PercentileSnapshot.PercentileSnapshot C# (CSharp) Method

PercentileSnapshot() public method

public PercentileSnapshot ( IEnumerable dataList ) : Jellyfish.Commands.Utils
dataList IEnumerable
return Jellyfish.Commands.Utils
        public PercentileSnapshot(IEnumerable<SnapshotItem> dataList)
        {
            long lengthFromBuckets = 0;

            // we need to calculate it dynamically as it could have been changed by properties (rare, but possible)
            // also this way we capture the actual index size rather than the max so size the int[] to only what we need
            foreach (var b in dataList)
            {
                lengthFromBuckets += b.Length;
            }

            data = new int[lengthFromBuckets];
            int index = 0;
            int sum = 0;
            foreach (var b in dataList)
            {
                int length = b.Length;
                for (int i = 0; i < length; i++)
                {
                    int v = b.Data[i];
                    this.data[index++] = v;
                    sum += v;
                }
            }
            this.length = index;
            if (this.length == 0)
            {
                this.mean = 0;
            }
            else
            {
                this.mean = sum / this.length;
            }

            Array.Sort(this.data, 0, length);
        }

Same methods

PercentileSnapshot::PercentileSnapshot ( ) : Jellyfish.Commands.Utils