using System.Collections.Concurrent;
using System.Linq;
namespace EonaCat.LogStack.Telemetry;
public sealed class Histogram
{
    private readonly ConcurrentQueue<double> _values = new();
    public void Record(double value){ _values.Enqueue(value); while(_values.Count>10000)_values.TryDequeue(out _); }
    public double Percentile(double p){ var a=_values.ToArray(); if(a.Length==0)return 0; System.Array.Sort(a); return a[(int)((a.Length-1)*p)]; }
}
