public void Run()
            {
                _globalSignal.Signal();
                _globalSignal.Wait();

                Thread.Sleep(1000);
                long counter = 0;

                while (counter < _maxEvents)
                {
                    var t0 = Stopwatch.GetTimestamp();
                    _pingQueue.Enqueue(1L);
                    counter += _pongQueue.Dequeue();
                    var t1 = Stopwatch.GetTimestamp();

                    _histogram.RecordValueWithExpectedInterval(LatencyTestSession.ConvertStopwatchTicksToNano(t1 - t0), _pauseTimeInNano);

                    while (_pauseDurationInStopwatchTicks > (Stopwatch.GetTimestamp() - t1))
                    {
                        Thread.Sleep(0);
                    }
                }

                _signal.Set();
            }
Example #2
0
        public void OnEvent(PerfEvent data, long sequence, bool endOfBatch)
        {
            var t1 = Stopwatch.GetTimestamp();

            _histogram.RecordValueWithExpectedInterval(LatencyTestSession.ConvertStopwatchTicksToNano(t1 - _t0), _pauseTimeNs);

            if (data.Value < _maxEvents)
            {
                while (_pauseTimeTicks > (Stopwatch.GetTimestamp() - t1))
                {
                    Thread.Yield();
                }

                Send();
            }
            else
            {
                _signal.Set();
            }
        }
        public ValueTask OnBatch(EventBatch <PingPongEvent> batch, long sequence)
        {
            foreach (var data in batch)
            {
                var t1 = Stopwatch.GetTimestamp();
                _histogram.RecordValueWithExpectedInterval(LatencyTestSession.ConvertStopwatchTicksToNano(t1 - _t0), _pauseTimeNs);

                if (data.Counter == _iterations)
                {
                    _completedSignal.Set();
                }
                else
                {
                    while (_pauseTimeTicks > Stopwatch.GetTimestamp() - t1)
                    {
                        Thread.Yield();
                    }

                    SendPing();
                }
            }

            return(ValueTask.CompletedTask);
        }