Exemple #1
0
        public override void onConnect()
        {
            Console.WriteLine("Client successfully connected");
            //return;

            /*Benchmark bench = new Benchmark();
             * while (true)
             * {
             *  bench.Bench(new BenchCallback(onBenchEvent));
             *
             *  if(bench.PastASecond)
             *  {
             *      Console.WriteLine("Speed:" + bench.SpeedPerSec);
             *  }
             * }*/



            while (false)
            {
                using (TestSocket testSock2 = new TestSocket(this))
                {
                    testSock2.Connect();
                    testSock2.Disconnect();
                }
                //Thread.Sleep(5000);
            }

            TestSocket testSock = new TestSocket(this);

            testSock.Connect();

            Stopwatch RuntimeSW = Stopwatch.StartNew();

            Benchmark bench = new Benchmark();

            while (true)
            {
                //Thread.Sleep(1);
                int size = 0;
                bench.Bench(new BenchCallback(() => size = testSock.SendStuff()));

                if (bench.PastASecond)
                {
                    ulong  Speed         = bench.SpeedPerSec * (ulong)testSock.testBytes.Length;
                    double MegaByteSpeed = Math.Round(((double)Speed / 1000F) / 1000F, 2);
                    double GigabitSpeed  = Math.Round((MegaByteSpeed / 1000F) * 8, 0);

                    Console.WriteLine("Speed:" + bench.SpeedPerSec + "(" + size + ")\t\t" + MegaByteSpeed + "MBps\t\t" + GigabitSpeed + "Gbps");
                    Console.Title = "SSP Client - Running for " + RuntimeSW.Elapsed.Hours + ":" + RuntimeSW.Elapsed.Minutes + ":" + RuntimeSW.Elapsed.Seconds;
                }
            }
        }