Exemple #1
0
        public void TestPerformance()
        {
            Action reflectionAction = () => AutoMapper.Build(typeof(Student), typeof(Person));
            Action emitAction       = () => AutoMapperEmit.Build(typeof(Student), typeof(Person));
            long   reflection       = Benchmark.Bench(reflectionAction, "Reflection - Person");
            long   emit             = Benchmark.Bench(emitAction, "Emit - Person");

            Assert.IsTrue(reflection < emit);
        }
Exemple #2
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;
                }
            }
        }