Esempio n. 1
0
        /// <summary>
        ///     Measures the current latency and calculates the average latency.
        /// </summary>
        internal bool MeasureLatency()
        {
            try
            {
                _stopwatch.Restart();
                _latencyGrain.Roundtrip();
                _stopwatch.Stop();
                var rtt = _stopwatch.Elapsed;

                lock (_syncRoot)
                {
                    _measurements.Enqueue(rtt);
                }

                return(true);
            }
            catch (RemoteProcedureCallCanceledException e)
            {
                Log.DebugFormat("{0}: Caught exception while measuring latency: {1}", _endPointName, e);
                return(false);
            }
            catch (Exception e)
            {
                Log.ErrorFormat("{0}: Caught unexpected exception while measuring latency: {1}", _endPointName, e);
                return(true);
            }
        }
Esempio n. 2
0
        private void AppendDelta(TimeSpan currentValue, ref TimeSpan previousValue, TimeSpanStatisticsContainer container)
        {
            var delta = currentValue - previousValue;

            previousValue = currentValue;
            container.Enqueue(delta);
        }