internal void Init(LabelValues labelValues, SummaryConfiguration configuration, DateTime now) { base.Init(labelValues, configuration); _sortedObjectives = new double[Configuration.Objectives.Count]; _buffer = new SampleBuffer(Configuration.BufCap); _streamDuration = new TimeSpan(Configuration.MaxAge.Ticks / Configuration.AgeBuckets); _headStreamExpTime = now.Add(_streamDuration); _bufferExpTime = _headStreamExpTime; _streams = new QuantileStream[Configuration.AgeBuckets]; for (int i = 0; i < Configuration.AgeBuckets; i++) { _streams[i] = QuantileStream.NewTargeted(Configuration.Objectives); } _headStream = _streams[0]; for (int i = 0; i < Configuration.Objectives.Count; i++) { _sortedObjectives[i] = Configuration.Objectives[i].Quantile; } Array.Sort(_sortedObjectives); }
public void TestTargetedQuery() { var random = new Random(42); var s = QuantileStream.NewTargeted(_targets); var a = PopulateStream(s, random); VerifyPercsWithAbsoluteEpsilon(a, s); }
public void TestDefaults() { var q = QuantileStream.NewTargeted(new List <QuantileEpsilonPair> { new QuantileEpsilonPair(0.99d, 0.001d) }); var g = q.Query(0.99); Assert.Equal(0, g); }
public void TestUncompressedOne() { var q = QuantileStream.NewTargeted(new List <QuantileEpsilonPair> { new QuantileEpsilonPair(0.99d, 0.001d) }); q.Insert(3.14); var g = q.Query(0.90); Assert.Equal(3.14, g); }
public void TestUncompressedSamples() { var q = QuantileStream.NewTargeted(new List <QuantileEpsilonPair> { new QuantileEpsilonPair(0.99d, 0.001d) }); for (var i = 1; i <= 100; i++) { q.Insert(i); } Assert.Equal(100, q.SamplesCount); }
public Summary(SummaryConfiguration configuration, IReadOnlyList <string> labels, Func <DateTimeOffset> currentTimeProvider = null) : base(configuration, labels, currentTimeProvider) { _buffer = new SampleBuffer(Configuration.BufCap); _streamDuration = new TimeSpan(Configuration.MaxAge.Ticks / Configuration.AgeBuckets); _headStreamExpTime = CurrentTimeProvider().Add(_streamDuration); _bufferExpTime = _headStreamExpTime; _streams = new QuantileStream[Configuration.AgeBuckets]; for (int i = 0; i < Configuration.AgeBuckets; i++) { _streams[i] = QuantileStream.NewTargeted(Configuration.Objectives); } _headStream = _streams[0]; }
public void TestUncompressed() { var q = QuantileStream.NewTargeted(_targets); for (var i = 100; i > 0; i--) { q.Insert(i); } Assert.Equal(100, q.Count); // Before compression, Query should have 100% accuracy foreach (var quantile in _targets.Select(_ => _.Quantile)) { var w = quantile * 100; var g = q.Query(quantile); Assert.Equal(g, w); } }
internal void Init(ICollector parent, LabelValues labelValues, DateTime now) { base.Init(parent, labelValues); _objectives = ((Summary)parent)._objectives; _maxAge = ((Summary)parent)._maxAge; _ageBuckets = ((Summary)parent)._ageBuckets; _bufCap = ((Summary)parent)._bufCap; _sortedObjectives = new double[_objectives.Count]; _hotBuf = new SampleBuffer(_bufCap); _coldBuf = new SampleBuffer(_bufCap); _streamDuration = new TimeSpan(_maxAge.Ticks / _ageBuckets); _headStreamExpTime = now.Add(_streamDuration); _hotBufExpTime = _headStreamExpTime; _streams = new QuantileStream[_ageBuckets]; for (var i = 0; i < _ageBuckets; i++) { _streams[i] = QuantileStream.NewTargeted(_objectives); } _headStream = _streams[0]; for (var i = 0; i < _objectives.Count; i++) { _sortedObjectives[i] = _objectives[i].Quantile; } Array.Sort(_sortedObjectives); _wireMetric = new CSummary { Quantiles = new CQuantile[_objectives.Count] }; for (int i = 0; i < _objectives.Count; i++) { _wireMetric.Quantiles[i] = new CQuantile { Quantile = _objectives[i].Quantile } } ; }
internal Child(Summary parent, Labels labels, bool publish) : base(parent, labels, publish) { _objectives = parent._objectives; _maxAge = parent._maxAge; _ageBuckets = parent._ageBuckets; _bufCap = parent._bufCap; _sortedObjectives = new double[_objectives.Count]; _hotBuf = new SampleBuffer(_bufCap); _coldBuf = new SampleBuffer(_bufCap); _streamDuration = new TimeSpan(_maxAge.Ticks / _ageBuckets); _headStreamExpTime = DateTime.Now.Add(_streamDuration); _hotBufExpTime = _headStreamExpTime; _streams = new QuantileStream[_ageBuckets]; for (var i = 0; i < _ageBuckets; i++) { _streams[i] = QuantileStream.NewTargeted(_objectives); } _headStream = _streams[0]; for (var i = 0; i < _objectives.Count; i++) { _sortedObjectives[i] = _objectives[i].Quantile; } Array.Sort(_sortedObjectives); _sumIdentifier = CreateIdentifier("sum"); _countIdentifier = CreateIdentifier("count"); _quantileIdentifiers = new byte[_objectives.Count][]; for (var i = 0; i < _objectives.Count; i++) { var value = double.IsPositiveInfinity(_objectives[i].Quantile) ? "+Inf" : _objectives[i].Quantile.ToString(CultureInfo.InvariantCulture); _quantileIdentifiers[i] = CreateIdentifier(null, ("quantile", value)); } }