public Pinger(RingBuffer <PerfEvent> buffer, long maxEvents, long pauseTimeNs) { _buffer = buffer; _maxEvents = maxEvents; _pauseTimeNs = pauseTimeNs; _pauseTimeTicks = LatencyTestSession.ConvertNanoToStopwatchTicks(pauseTimeNs); }
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(); }
private async Task Run() { _globalSignal.Signal(); _globalSignal.Wait(); Thread.Sleep(1000); long counter = 0; while (counter < _maxEvents) { var t0 = Stopwatch.GetTimestamp(); await _pingChannel.Writer.WriteAsync(new PerfEvent { Value = 1 }); await _pongChannel.Reader.ReadAsync(); var t1 = Stopwatch.GetTimestamp(); counter++; _histogram.RecordValueWithExpectedInterval(LatencyTestSession.ConvertStopwatchTicksToNano(t1 - t0), _pauseTimeInNano); while (_pauseDurationInStopwatchTicks > (Stopwatch.GetTimestamp() - t1)) { Thread.Sleep(0); } } await _pingChannel.Writer.WriteAsync(new PerfEvent { Value = -1 }); }
public QueuePinger(ArrayConcurrentQueue <long> pingQueue, ArrayConcurrentQueue <long> pongQueue, long maxEvents, long pauseTimeInNano) { _pingQueue = pingQueue; _pongQueue = pongQueue; _maxEvents = maxEvents; _pauseTimeInNano = pauseTimeInNano; _pauseDurationInStopwatchTicks = LatencyTestSession.ConvertNanoToStopwatchTicks(pauseTimeInNano); }
public Pinger(RingBuffer <ValueEvent> buffer, long maxEvents, int pauseDurationInNanos) { _buffer = buffer; _maxEvents = maxEvents; _pauseDurationInNanos = pauseDurationInNanos; _pauseDurationInStopwatchTicks = LatencyTestSession.ConvertNanoToStopwatchTicks(pauseDurationInNanos); }
public QueuePinger(Channel <PerfEvent> pingChannel, Channel <PerfEvent> pongChannel, long maxEvents, long pauseTimeInNano) { _pingChannel = pingChannel; _pongChannel = pongChannel; _maxEvents = maxEvents; _pauseTimeInNano = pauseTimeInNano; _pauseDurationInStopwatchTicks = LatencyTestSession.ConvertNanoToStopwatchTicks(pauseTimeInNano); }
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(); } }
private static void RunTestForType(Type perfTestType, Options options) { var isThroughputTest = typeof(IThroughputTest).IsAssignableFrom(perfTestType); if (isThroughputTest) { var session = new ThroughputTestSession(perfTestType); session.Run(options); session.Report(options); } var isLatencyTest = typeof(ILatencyTest).IsAssignableFrom(perfTestType); if (isLatencyTest) { var session = new LatencyTestSession(perfTestType); session.Run(options); session.Report(options); } }
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); }