public void SetUp(BenchmarkContext context) { ClientGroup = new MultithreadEventLoopGroup(1); ServerGroup = new MultithreadEventLoopGroup(1); WorkerGroup = new MultithreadEventLoopGroup(); var iso = Encoding.GetEncoding("ISO-8859-1"); message = iso.GetBytes("ABC"); // pre-allocate all messages foreach (var m in Enumerable.Range(0, WriteCount)) { messages[m] = Unpooled.WrappedBuffer(message); } _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent); var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel <TcpServerSocketChannel>() .ChildOption(ChannelOption.TcpNodelay, true) .ChildHandler( new ActionChannelInitializer <TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); var cb = new ClientBootstrap().Group(ClientGroup) .Option(ChannelOption.TcpNodelay, true) .Channel <TcpSocketChannel>().Handler(new ActionChannelInitializer <TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()).AddLast(GetDecoder()).AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server _clientChannel = cb.ConnectAsync(_serverChannel.LocalAddress).Result; //_clientChannel.Configuration.AutoRead = false; }
public void SetUp(BenchmarkContext context) { ClientGroup = new MultithreadEventLoopGroup(1); ServerGroup = new MultithreadEventLoopGroup(2); var iso = Encoding.GetEncoding("ISO-8859-1"); message = iso.GetBytes("ABC"); _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new SimpleReadFinishedSignal(); var sb = new ServerBootstrap().Group(ServerGroup).Channel <LocalServerChannel>() .ChildHandler( new ActionChannelInitializer <LocalChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); var cb = new ClientBootstrap().Group(ClientGroup) .Channel <LocalChannel>() .Handler(new ActionChannelInitializer <LocalChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()).AddLast(GetDecoder()).AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server _clientChannel = cb.ConnectAsync(_serverChannel.LocalAddress).Result; }
public void SetUp(BenchmarkContext context) { ServerGroup = new MultithreadEventLoopGroup(1); WorkerGroup = new MultithreadEventLoopGroup(); var iso = Encoding.GetEncoding("ISO-8859-1"); message = Unpooled.Buffer().WriteInt(3).WriteBytes(iso.GetBytes("ABC")).ToArray(); _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent); var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel <TcpServerSocketChannel>() .ChildOption(ChannelOption.TcpNodelay, true) .ChildHandler( new ActionChannelInitializer <TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server var address = (IPEndPoint)_serverChannel.LocalAddress; ClientSocket = new System.Net.Sockets.Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); ClientSocket.Connect(address.Address, address.Port); Stream = new NetworkStream(ClientSocket, true); }
public void SetUp(BenchmarkContext context) { ServerGroup = new MultithreadEventLoopGroup(1); WorkerGroup = new MultithreadEventLoopGroup(); var iso = Encoding.GetEncoding("ISO-8859-1"); message = Unpooled.Buffer().WriteInt(3).WriteBytes(iso.GetBytes("ABC")).ToArray(); _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent); var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel<TcpServerSocketChannel>() .ChildOption(ChannelOption.TcpNodelay, true) .ChildHandler( new ActionChannelInitializer<TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server var address = (IPEndPoint) _serverChannel.LocalAddress; ClientSocket = new System.Net.Sockets.Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); ClientSocket.Connect(address.Address, address.Port); Stream = new NetworkStream(ClientSocket, true); }
public void SetUp(BenchmarkContext context) { ClientGroup = new MultithreadEventLoopGroup(1); ServerGroup = new MultithreadEventLoopGroup(1); WorkerGroup = new MultithreadEventLoopGroup(); var iso = Encoding.GetEncoding("ISO-8859-1"); message = iso.GetBytes("ABC"); // pre-allocate all messages foreach (var m in Enumerable.Range(0, WriteCount)) { messages[m] = Unpooled.WrappedBuffer(message); } _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent); var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel<TcpServerSocketChannel>() .ChildOption(ChannelOption.TcpNodelay, true) .ChildHandler( new ActionChannelInitializer<TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); var cb = new ClientBootstrap().Group(ClientGroup) .Option(ChannelOption.TcpNodelay, true) .Channel<TcpSocketChannel>().Handler(new ActionChannelInitializer<TcpSocketChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()).AddLast(GetDecoder()).AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server _clientChannel = cb.ConnectAsync(_serverChannel.LocalAddress).Result; //_clientChannel.Configuration.AutoRead = false; }
public void SetUp(BenchmarkContext context) { ClientGroup = new MultithreadEventLoopGroup(1); ServerGroup = new MultithreadEventLoopGroup(2); var iso = Encoding.GetEncoding("ISO-8859-1"); message = iso.GetBytes("ABC"); _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter); _signal = new SimpleReadFinishedSignal(); var sb = new ServerBootstrap().Group(ServerGroup).Channel<LocalServerChannel>() .ChildHandler( new ActionChannelInitializer<LocalChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)) .AddLast(new ReadFinishedHandler(_signal, WriteCount)); })); var cb = new ClientBootstrap().Group(ClientGroup) .Channel<LocalChannel>() .Handler(new ActionChannelInitializer<LocalChannel>( channel => { channel.Pipeline.AddLast(GetEncoder()).AddLast(GetDecoder()).AddLast(counterHandler) .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter)); })); // start server _serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server _clientChannel = cb.ConnectAsync(_serverChannel.LocalAddress).Result; }