Example #1
0
        private static void TestPerf(String name, int iter, Messagizer m, Message msg, int n)
        {
            long t0 = HPTimer.Now();

            for (int i = 0; i < n; i++)
            {
                m.TransportMessage(null, msg);
            }

            long t1 = HPTimer.NsSince(t0);

            double timeDiff = t1 / 1000000000.0;
            double r        = n / timeDiff;

            Console.WriteLine(name + " -- iteration : " + iter + " time : " + timeDiff +
                              " count : " + n + " rate : " + r);
        }
Example #2
0
        public void Test_add_perf()
        {
            vf = new MyValueFactory();

            XType add = vf.GetType("add");

            Field x = new Field("x");

            add.PutValidator(x, Validator_int.Get(0));

            Field y = new Field("y");

            add.PutValidator(y, Validator_int.Get(0));

            Field _mf__messageId = DefaultValueFactory._mf__messageId;

            add.PutValidator(_mf__messageId, Validator_long.Get(0));

            long msgid = 0x0123456789abcdefL;

            Message msg = new Message(add, vf);

            msg.Add(x, 123456789);
            msg.Add(y, 876543210);
            msg.Add(_mf__messageId, msgid);

            Resources res = new Resources();

            res.Add(TransportConsts.VALUE_FACTORY, vf);
            MyPacketSource ps = new MyPacketSource();
            Messagizer     m  = new Messagizer(ps, "foo:?Messagizer.format=binary", res);

            m.TransportMessage(null, msg);


            int n = 900973;

            for (int i = 0; i < 3; i++)
            {
                TestPerf("test_add_perf", i, m, msg, n);
            }
        }
Example #3
0
        public void Test_sum_perf()
        {
            XType sum = vf.GetType("sum");

            Field values = new Field("values");

            sum.PutValidator(values, Validator_int.Get(1));

            Field _mf__messageId = DefaultValueFactory._mf__messageId;

            sum.PutValidator(_mf__messageId, Validator_long.Get(0));

            long msgid = 0x0123456789abcdefL;

            int[] array = new int[2];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = 123456789;
            }

            Message msg = new Message(sum, vf);

            msg.Add(values, array);
            msg.Add(_mf__messageId, msgid);

            Resources res = new Resources();

            res.Add(TransportConsts.VALUE_FACTORY, vf);
            MyPacketSource ps = new MyPacketSource();
            Messagizer     m  = new Messagizer(ps, "foo:?Messagizer.format=binary", res);

            m.TransportMessage(null, msg);

            int n = 509520;

            for (int i = 0; i < 1; i++)
            {
                TestPerf("test_sum_perf", i, m, msg, n);
            }
        }