protected TimeSpan ComputeNewTimeOut(double ms, TimeStats stats, double min, double stdevs) { stats.AddSample(ms); double timeout = stats.Average + stdevs * stats.StdDev; timeout = Math.Max(min, timeout); return(TimeSpan.FromMilliseconds(timeout)); }
public void AddAckSampleFor(RequestState reqs, ISender s, TimeSpan rtt) { lock ( _sync ) { var tsp = GetStatsFor(s); tsp.First.AddSample(rtt.TotalMilliseconds); tsp.Second.AddSample(rtt.TotalMilliseconds); _global_stats.AddSample(rtt.TotalMilliseconds); //Update the minimum: _min_timeout = Math.Min(_min_timeout, tsp.First.AvePlusKStdDev(_STD_DEVS)); _min_timeout = Math.Min(_min_timeout, tsp.Second.AvePlusKStdDev(_STD_DEVS)); _min_timeout = Math.Min(_min_timeout, _global_stats.AvePlusKStdDev(_STD_DEVS)); } }
public void AddReplySampleFor(RequestState reqs, ISender s, TimeSpan rtt) { /* * Let's look at how long it took to get this reply: */ if (reqs.GotAck) { lock (_sync) { TimeStats ts = _acked_rtt_stats; ts.AddSample(rtt.TotalMilliseconds); _min_timeout = Math.Min(_min_timeout, ts.AvePlusKStdDev(_STD_DEVS)); } } else { AddAckSampleFor(reqs, s, rtt); } }
protected TimeSpan ComputeNewTimeOut(double ms, TimeStats stats, double min, double stdevs) { stats.AddSample(ms); double timeout = stats.Average + stdevs * stats.StdDev; timeout = Math.Max(min, timeout); return TimeSpan.FromMilliseconds( timeout ); }