static void RunTcpBenchmark(string name) { if (string.IsNullOrEmpty(name) || string.Compare(name, "writeBatch", StringComparison.CurrentCultureIgnoreCase) == 0) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(TcpWriteBatch)}"); using (var tcpWriteBatch = new TcpWriteBatch()) { tcpWriteBatch.Run(); } } if (string.IsNullOrEmpty(name) || string.Compare(name, "pingPong", StringComparison.CurrentCultureIgnoreCase) == 0) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(TcpPingPong)}"); using (var tcpPingPong = new TcpPingPong()) { tcpPingPong.Run(); } } if (string.IsNullOrEmpty(name) || string.Compare(name, "pump", StringComparison.CurrentCultureIgnoreCase) == 0) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pump)} (1)"); using (var tcpPump = new Pump(HandleType.Tcp, 1)) { tcpPump.Run(); } if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pump)} (100)"); using (var tcpPump = new Pump(HandleType.Tcp, 100)) { tcpPump.Run(); } } } if (string.IsNullOrEmpty(name) || string.Compare(name, "pound", StringComparison.CurrentCultureIgnoreCase) == 0) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pound)} (100)"); using (var tcpPound = new Pound(HandleType.Tcp, 100)) { tcpPound.Run(); } Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pound)} (1000)"); using (var tcpPound = new Pound(HandleType.Tcp, 1000)) { tcpPound.Run(); } } }
static void RunTcpBenchmark(IReadOnlyCollection <string> list) { if (list.Contains("tcpWriteBatch", StringComparer.OrdinalIgnoreCase)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(TcpWriteBatch)}"); using (var tcpWriteBatch = new TcpWriteBatch()) { tcpWriteBatch.Run(); } } if (list.Contains("tcpPingPong", StringComparer.OrdinalIgnoreCase)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(TcpPingPong)}"); using (var tcpPingPong = new TcpPingPong()) { tcpPingPong.Run(); } } if (list.Contains("tcpPump", StringComparer.OrdinalIgnoreCase)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pump)} (1)"); using (var tcpPump = new Pump(HandleType.Tcp, 1)) { tcpPump.Run(); } if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pump)} (100)"); using (var tcpPump = new Pump(HandleType.Tcp, 100)) { tcpPump.Run(); } } } if (list.Contains("tcpPound", StringComparer.OrdinalIgnoreCase)) { Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pound)} (100)"); using (var tcpPound = new Pound(HandleType.Tcp, 100)) { tcpPound.Run(); } Console.WriteLine($"{nameof(RunTcpBenchmark)} {nameof(Pound)} (1000)"); using (var tcpPound = new Pound(HandleType.Tcp, 1000)) { tcpPound.Run(); } } }