Side-by-side performance benchmarks using NATS.Client.Core against both servers on ephemeral ports. Includes core pub/sub, request/reply latency, and JetStream throughput tests with comparison output and benchmarks_comparison.md results. Also fixes timestamp flakiness in StoreInterfaceTests by using explicit timestamps.
15 lines
414 B
C#
15 lines
414 B
C#
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace NATS.Server.Benchmark.Tests.Infrastructure;
|
|
|
|
internal static class PortAllocator
|
|
{
|
|
public static int AllocateFreePort()
|
|
{
|
|
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
|
|
return ((IPEndPoint)socket.LocalEndPoint!).Port;
|
|
}
|
|
}
|