public long Take_Time(long time, Action<int, Mess> testFuncion)
        {
            var watch = new Stopwatch();
            Mess mess = new MessA();
            watch.Start();
            for (long i = 0; i < time; i++)
            {
                testFuncion(5, mess);
            }

            watch.Stop();

            return watch.ElapsedTicks;
        }
Esempio n. 2
0
        public long Take_Time(long time, Action <int, Mess> testFuncion)
        {
            var  watch = new Stopwatch();
            Mess mess  = new MessA();

            watch.Start();
            for (long i = 0; i < time; i++)
            {
                testFuncion(5, mess);
            }

            watch.Stop();

            return(watch.ElapsedTicks);
        }
        public void Run(long time, long tries)
        {
            MessageSender.CacheAssemblieMessages(typeof(MessA).Assembly);
            MessA messa = new MessA();
            ScriptMethod del = new ScriptMethod("Method2");
            del.TrackInstance(messa);

            long dC = 0, mC = 0, sM = 0;
            for (int i = 0; i < tries; i++)
            {
                dC += Take_Time(time, (num, m) => m.Method2());
                mC += Take_Time(time, (num, m) => MessageSender.SendMessage(m, "Method2", null, MessageOptions.DontRequireReceiver));
                sM += Take_Time(time, (num, m) => del.Method.Invoke());
            }

            Console.WriteLine("Direct_Call mean: " + ((decimal)dC / (decimal)tries));
            Console.WriteLine("Message_Call mean: " + ((decimal)mC / (decimal)tries));
            Console.WriteLine("ScripMethod_Call mean: " + ((decimal)sM / (decimal)tries));
            Console.WriteLine("The ratio of calls is: " + ((decimal)mC / (decimal)dC));
        }
Esempio n. 4
0
        public void Run(long time, long tries)
        {
            MessageSender.CacheAssemblieMessages(typeof(MessA).Assembly);
            MessA        messa = new MessA();
            ScriptMethod del   = new ScriptMethod("Method2");

            del.TrackInstance(messa);


            long dC = 0, mC = 0, sM = 0;

            for (int i = 0; i < tries; i++)
            {
                dC += Take_Time(time, (num, m) => m.Method2());
                mC += Take_Time(time, (num, m) => MessageSender.SendMessage(m, "Method2", null, MessageOptions.DontRequireReceiver));
                sM += Take_Time(time, (num, m) => del.Method.Invoke());
            }

            Console.WriteLine("Direct_Call mean: " + ((decimal)dC / (decimal)tries));
            Console.WriteLine("Message_Call mean: " + ((decimal)mC / (decimal)tries));
            Console.WriteLine("ScripMethod_Call mean: " + ((decimal)sM / (decimal)tries));
            Console.WriteLine("The ratio of calls is: " + ((decimal)mC / (decimal)dC));
        }