public static (double, double, TimeSpan) RunBig() { var serverCancellationSource = new CancellationTokenSource(); var clientCancellationSource = new CancellationTokenSource(); var stopWatch = Stopwatch.StartNew(); TimeSpan elapesedTime; ulong writer_count = 0, reader_count = 0; try { var sw = new SocketWriter(); var sr = new SocketReader(); var socks = LocalSocketRunner.GetLocalSockets(); var wirter = sw.Run(DataType.Big, serverCancellationSource.Token, socks.Server); var reader = sr.Run(DataType.Big, clientCancellationSource.Token, socks.Client); serverCancellationSource.CancelAfter(TimeSpan.FromSeconds(10)); writer_count = wirter.Result; clientCancellationSource.Cancel(); reader_count = reader.Result; } catch (Exception e) { Console.WriteLine(e.StackTrace); } finally { elapesedTime = stopWatch.Elapsed; stopWatch.Stop(); } double readen_kbPerS = (reader_count / 1024) / elapesedTime.TotalSeconds; double writen_kbPerS = (writer_count / 1024) / elapesedTime.TotalSeconds; return(readen_kbPerS, writen_kbPerS, elapesedTime); }
static void Main(string[] args) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("NEW TESTRUN"); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("LocalHost -----"); //var ls = new LocalSocketUnserializer(); //var (readen1, ts, time1) = ls.RunBigAsync(); //Console.WriteLine($"DATARATE - in {Math.Round(time1.TotalSeconds, 4)}s Readen {Math.Round(readen1, 2)} kB/s - Serialization took {Math.Round(ts.TotalSeconds, 4)} s"); // var (readen, stime, rtime) = ls.RunBig(); // Console.WriteLine($"DATARATE - in {Math.Round(rtime.TotalSeconds, 4)}s Readen {Math.Round(readen, 2)} kB/s - Serialization took {Math.Round(stime.TotalSeconds, 4)} s"); Console.WriteLine("LocalHost -----"); var(readen2, writen2, time2) = LocalSocketRunner.RunSmall(); Console.WriteLine($"DATARATE - in {Math.Round(time2.TotalSeconds, 4)}s Readen {Math.Round(readen2, 2)} kB/s - Writen {Math.Round(writen2, 2)} kB/s"); Console.WriteLine("FirstIP ------"); var(readen1, writen1, time1) = TcpSocketRunner.RunBig(); Console.WriteLine($"DATARATE - in {Math.Round(time1.TotalSeconds, 4)}s Readen {Math.Round(readen1, 2)} kB/s - Writen {Math.Round(writen1, 2)} kB/s"); (readen2, writen2, time2) = TcpSocketRunner.RunSmall(); Console.WriteLine($"DATARATE - in {Math.Round(time2.TotalSeconds, 4)}s Readen {Math.Round(readen2, 2)} kB/s - Writen {Math.Round(writen2, 2)} kB/s"); (readen2, writen2, time2) = LocalSocketRunner.RunSmall(); Console.WriteLine($"DATARATE - in {Math.Round(time2.TotalSeconds, 4)}s Readen {Math.Round(readen2, 2)} kB/s - Writen {Math.Round(writen2, 2)} kB/s"); Console.WriteLine("UnixSocket ----"); (readen1, writen1, time1) = UnixSocketRunner.RunBig(); Console.WriteLine($"DATARATE - in {Math.Round(time1.TotalSeconds, 4)}s Readen {Math.Round(readen1, 2)} kB/s - Writen {Math.Round(writen1, 2)} kB/s"); (readen2, writen2, time2) = UnixSocketRunner.RunSmall(); Console.WriteLine($"DATARATE - in {Math.Round(time2.TotalSeconds, 4)}s Readen {Math.Round(readen2, 2)} kB/s - Writen {Math.Round(writen2, 2)} kB/s"); Console.WriteLine("-----"); }