public void NoEviction_Max() { var eq = new EvictingQueue <int>(4); Assert.Equal(0, eq.Count); Assert.Equal(0, eq.DroppedItems); eq.Add(0); Assert.Equal(1, eq.Count); Assert.Equal(0, eq.DroppedItems); eq.Add(1); Assert.Equal(2, eq.Count); Assert.Equal(0, eq.DroppedItems); eq.Add(2); Assert.Equal(3, eq.Count); Assert.Equal(0, eq.DroppedItems); eq.Add(3); Assert.Equal(4, eq.Count); Assert.Equal(0, eq.DroppedItems); var items = eq.ToArray(); Assert.Equal(4, items.Length); Assert.Equal(0, items[0]); Assert.Equal(1, items[1]); Assert.Equal(2, items[2]); Assert.Equal(3, items[3]); }
public void NoReplacing() { var eq = new EvictingQueue <int>(1) { 0 }; eq.Replace(1, 1); var items = eq.ToArray(); Assert.Equal(0, items[0]); }
public static void GetSamples( int maxSpansToReturn, List <SpanBase> output, EvictingQueue <SpanBase> queue) { SpanBase[] copy = queue.ToArray(); foreach (SpanBase span in copy) { if (output.Count >= maxSpansToReturn) { break; } output.Add(span); } }
public void NoEviction() { var eq = new EvictingQueue <int>(4) { 0, 1, 2 }; var items = eq.ToArray(); Assert.Equal(3, items.Length); Assert.Equal(0, items[0]); Assert.Equal(1, items[1]); Assert.Equal(2, items[2]); }
public static void GetSamples( int maxSpansToReturn, ICollection <SpanBase> output, EvictingQueue <SpanBase> queue) { var copy = queue.ToArray(); foreach (var span in copy) { if (output.Count >= maxSpansToReturn) { break; } output.Add(span); } }
public void Eviction() { var eq = new EvictingQueue <int>(4) { 0, 1, 2, 3, 4 }; Assert.Equal(4, eq.Count); Assert.Equal(1, eq.DroppedItems); var items = eq.ToArray(); Assert.Equal(4, items.Length); Assert.Equal(1, items[0]); Assert.Equal(2, items[1]); Assert.Equal(3, items[2]); Assert.Equal(4, items[3]); }
public static void GetSamplesFilteredByLatency( long latencyLowerNs, long latencyUpperNs, int maxSpansToReturn, List <SpanBase> output, EvictingQueue <SpanBase> queue) { SpanBase[] copy = queue.ToArray(); foreach (SpanBase span in copy) { if (output.Count >= maxSpansToReturn) { break; } long spanLatencyNs = span.LatencyNs; if (spanLatencyNs >= latencyLowerNs && spanLatencyNs < latencyUpperNs) { output.Add(span); } } }
public static void GetSamplesFilteredByLatency( TimeSpan latencyLower, TimeSpan latencyUpper, int maxSpansToReturn, ICollection <SpanBase> output, EvictingQueue <SpanBase> queue) { SpanBase[] copy = queue.ToArray(); foreach (SpanBase span in copy) { if (output.Count >= maxSpansToReturn) { break; } var spanLatency = span.Latency; if (spanLatency >= latencyLower && spanLatency < latencyUpper) { output.Add(span); } } }