Ejemplo n.º 1
0
        public void Setup()
        {
            _pm        = new ProtocolMessage.ProtocolMessageManager();
            _goodMsg   = new BasicMessage("say", _goodArgs);
            _badMsgAt0 = new BasicMessage("say", _badArgsAt0);
            _badMsgAt1 = new BasicMessage("say", _badArgsAt1);
            _badType   = new BasicMessage("sya", _goodArgs);
            _chat      = new Chat {
                Message  = "hello world",
                PlayerId = 10
            };

            // dry run, ensure caching in decorator is fine
            BasicDeserialize();

            for (var i = 0; i < 2; i++)
            {
                BasicDeserialize();
                ProtocolMessage();
                DeserializeWithType();
                InvalidChat_At0();
                InvalidChat_At1();
                InvalidChat_Type();
            }
        }
Ejemplo n.º 2
0
        public Benchmarks()
        {
            _testClass = new TestClass
            {
                String       = "Hello, World!",
                Int          = 1234,
                SomeIntegers = new[]
                {
                    1, 2, 8, 9, 20, 15
                },
                LongInt          = 1106300L,
                UltraLongInt     = 11063002uL,
                Identifier       = 0xFF,
                SuperUselessByte = 0x0A,
            };

            _data = DConverter <TestClass> .Serialize(_testClass);

            _pm = new ProtocolMessage.ProtocolMessageManager();

            if (!(new ConverterContainer().RequestConverter <TestClass>() is ILConverter <TestClass> ilConv))
            {
                throw new Exception($"IL is not fully spported for the benchmarks yet.");
            }

            _tc = ilConv;

            foreach (var benchmark in GetType()
                     .GetMethods()
                     .Where(x => x.GetCustomAttributes(true)
                            .OfType <BenchmarkAttribute>()
                            .Count() > 0))
            {
                benchmark.Invoke(this, null);
            }
        }