Example #1
0
        public void SerializerGeneration()
        {
            var tester = new FirstCallTester(Console.Out);

            tester.Start();
            var msg = new Messages();

            tester.Stop();
            tester.Start();
            CreateProto();
            tester.Stop();
            tester.Start();
            CreateProto();
            tester.Stop();
            tester.Report();

            var reportwatch = new Reportwatch();

            reportwatch.Start("Protobuf");
            var proto = ProtoBuf.Meta.TypeModel.Create();

            proto.Add(typeof(UserInfo), true);
            proto.CompileInPlace();

            reportwatch.Stop("Protobuf");

            reportwatch.Start("Protobuf serialize");
            proto.Serialize(new MemoryStream(), CreateObj());
            reportwatch.Stop("Protobuf serialize");

            reportwatch.Start("Protobuf serialize 2");
            proto.Serialize(new MemoryStream(), CreateObj());
            reportwatch.Stop("Protobuf serialize 2");

            reportwatch.Start("DataContractSerializer ctor");
            DataContractSerializer xml = new DataContractSerializer(typeof(UserInfo));

            reportwatch.Stop("DataContractSerializer ctor");

            reportwatch.Start("DataContractSerializer serialize");
            xml.WriteObject(new MemoryStream(), CreateObj());
            reportwatch.Stop("DataContractSerializer serialize");

            reportwatch.Start("DataContractSerializer serialize 2");
            xml.WriteObject(new MemoryStream(), CreateObj());
            reportwatch.Stop("DataContractSerializer serialize 2");

            reportwatch.Report("Protobuf");
            reportwatch.Report("Protobuf serialize");
            reportwatch.Report("Protobuf serialize 2");
            reportwatch.Report("DataContractSerializer ctor");
            reportwatch.Report("DataContractSerializer serialize");
            reportwatch.Report("DataContractSerializer serialize 2");

            Assert.IsTrue(reportwatch.GetTime(new Regex("(Protobuf)")) <= reportwatch.GetTime(new Regex("(DataContractSerializer)")));
        }
Example #2
0
 public void NamedPipe_byteArray()
 {
     var tester = new FirstCallTester(Console.Out);
     tester.Start("1 Service");
     DoWcfHost();
     tester.Stop();
     tester.Start("2 Service2");
     DoWcfHost2();
     tester.Stop();
     tester.Start("3 Service2");
     DoWcfHost2();
     tester.Report();
 }
        public void SerializerGeneration()
        {
            var tester = new FirstCallTester(Console.Out);
            tester.Start();
            var msg = new Messages();
            tester.Stop();
            tester.Start();
            CreateProto();
            tester.Stop();
            tester.Start();
            CreateProto();
            tester.Stop();
            tester.Report();

            var reportwatch = new Reportwatch();
            reportwatch.Start("Protobuf");
            var proto = ProtoBuf.Meta.TypeModel.Create();
            proto.Add(typeof(UserInfo), true);
            proto.CompileInPlace();

            reportwatch.Stop("Protobuf");

            reportwatch.Start("Protobuf serialize");
            proto.Serialize(new MemoryStream(), CreateObj());
            reportwatch.Stop("Protobuf serialize");

            reportwatch.Start("Protobuf serialize 2");
            proto.Serialize(new MemoryStream(), CreateObj());
            reportwatch.Stop("Protobuf serialize 2");

            reportwatch.Start("DataContractSerializer ctor");
            DataContractSerializer xml = new DataContractSerializer(typeof(UserInfo));
            reportwatch.Stop("DataContractSerializer ctor");

            reportwatch.Start("DataContractSerializer serialize");
            xml.WriteObject(new MemoryStream(), CreateObj());
            reportwatch.Stop("DataContractSerializer serialize");

            reportwatch.Start("DataContractSerializer serialize 2");
            xml.WriteObject(new MemoryStream(), CreateObj());
            reportwatch.Stop("DataContractSerializer serialize 2");

            reportwatch.Report("Protobuf");
            reportwatch.Report("Protobuf serialize");
            reportwatch.Report("Protobuf serialize 2");
            reportwatch.Report("DataContractSerializer ctor");
            reportwatch.Report("DataContractSerializer serialize");
            reportwatch.Report("DataContractSerializer serialize 2");

            Assert.IsTrue(reportwatch.GetTime(new Regex("(Protobuf)")) <= reportwatch.GetTime(new Regex("(DataContractSerializer)")));
        }
Example #4
0
        public void NamedPipe_byteArray()
        {
            var tester = new FirstCallTester(Console.Out);

            tester.Start("1 Service");
            DoWcfHost();
            tester.Stop();
            tester.Start("2 Service2");
            DoWcfHost2();
            tester.Stop();
            tester.Start("3 Service2");
            DoWcfHost2();
            tester.Report();
        }
Example #5
0
        public void StartUpTime()
        {
            var testerRealProxy = new FirstCallTester(Console.Out);

            CreateRealProxy(testerRealProxy);
            testerRealProxy.Report();

            var testerUnity = new FirstCallTester(Console.Out);

            CreateUnityInerceptor(testerUnity);
            testerUnity.Report();
            Console.WriteLine();
            Console.WriteLine(testerRealProxy.Elapsed);
            Console.WriteLine(testerUnity.Elapsed);
            Assert.IsTrue(testerRealProxy.Elapsed.Ticks < 10 * testerUnity.Elapsed.Ticks);
        }
Example #6
0
        public void Ipc_byteArray()
        {
            var binding = new LocalBinding {
                MaxConnections = 5
            };
            var path   = "ipc:///" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var tester = new FirstCallTester(Console.Out);

            tester.Start("1 Service");
            DoWcfHost(binding, path);
            tester.Stop();
            tester.Start("2 Service2");
            DoWcfHost2(binding, path);
            tester.Stop();
            tester.Start("3 Service2");
            DoWcfHost2(binding, path);
            tester.Stop();
            tester.Start("4 Service2");
            DoWcfHost2(binding, path);
            tester.Stop();
            tester.Report();
        }
Example #7
0
 public void Ipc_byteArray()
 {
     var binding = new LocalBinding { MaxConnections = 5 };
     var path = "ipc:///" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
     var tester = new FirstCallTester(Console.Out);
     tester.Start("1 Service");
     DoWcfHost(binding, path);
     tester.Stop();
     tester.Start("2 Service2");
     DoWcfHost2(binding, path);
     tester.Stop();
     tester.Start("3 Service2");
     DoWcfHost2(binding, path);
     tester.Stop();
     tester.Start("4 Service2");
     DoWcfHost2(binding, path);
     tester.Stop();
     tester.Report();
 }
Example #8
0
        public void StartUpTime()
        {
            var testerRealProxy = new FirstCallTester(Console.Out);
            CreateRealProxy(testerRealProxy);
            testerRealProxy.Report();

            var testerUnity = new FirstCallTester(Console.Out);
            CreateUnityInerceptor(testerUnity);
            testerUnity.Report();
            Console.WriteLine();
            Console.WriteLine(testerRealProxy.Elapsed);
            Console.WriteLine(testerUnity.Elapsed);
            Assert.IsTrue(testerRealProxy.Elapsed.Ticks < 10*testerUnity.Elapsed.Ticks);
        }