Esempio n. 1
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));
        }