예제 #1
0
        private static IKnownType CreateRealProxy(FirstCallTester tester)
        {
            tester.Start("RealProxy");
            var realProxy = new RealProxyProxy().GetTransparentProxy();

            tester.Stop();
            tester.Start("RealProxySecond");
            var realProxy2 = new RealProxyProxy().GetTransparentProxy() as IRuntimeType;

            tester.Stop();
            tester.Start("as KnownType");
            var known = realProxy as IKnownType;

            tester.Stop();
            tester.Start("RealProxyKnownDo");
            known.KnownDo();
            tester.Stop();
            tester.Start("RealProxyKnownDoSecond");
            known.KnownDo();
            tester.Stop();
            tester.Start("RealProxyKnownDo1");
            known.KnownDo1(0, "");
            tester.Stop();
            return(realProxy as IKnownType);
        }
예제 #2
0
        private static IKnownType CreateUnityInerceptor(FirstCallTester tester)
        {
            var realProxy = new RealProxyProxy().GetTransparentProxy();

            tester.Start("InterfaceIntercepted");
            var interceptor = Intercept.ThroughProxy(typeof(IKnownType), realProxy, new InterfaceInterceptor(),
                                                     new[] { new NullInterceptionBehaviour() });

            tester.Stop();
            tester.Start("InterfaceInterceptedSecond");
            var interceptor2 = Intercept.ThroughProxy(typeof(IRuntimeType), realProxy as IRuntimeType, new InterfaceInterceptor(),
                                                      new[] { new NullInterceptionBehaviour() });

            tester.Stop();
            tester.Start("as KnownType");
            var known = interceptor as IKnownType;

            tester.Stop();
            tester.Start("KnownDo");
            known.KnownDo();
            tester.Stop();
            tester.Start("KnownDoSecond");
            known.KnownDo();
            tester.Stop();
            tester.Start("KnownDo1");
            known.KnownDo1(0, "");
            tester.Stop();
            return(interceptor as IKnownType);
        }
예제 #3
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)")));
        }
예제 #4
0
        public void ThroughtputTime()
        {
            var tester1 = new FirstCallTester(Console.Out);
            var tester2 = new FirstCallTester(Console.Out);

            var real  = CreateRealProxy(tester1);
            var unity = CreateUnityInerceptor(tester2);

            SpeedTesting.Do(Console.Out, 5, 10000, (r) => RealTime(r, real), (r) => UnityTime(r, unity));
        }
예제 #5
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)")));
        }
예제 #7
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();
        }
예제 #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);
        }
예제 #9
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();
 }
예제 #10
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();
        }
예제 #11
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);
        }
예제 #12
0
        private static IKnownType CreateUnityInerceptor(FirstCallTester tester)
        {
            var realProxy = new RealProxyProxy().GetTransparentProxy();
            tester.Start("InterfaceIntercepted");
            var interceptor = Intercept.ThroughProxy(typeof (IKnownType), realProxy, new InterfaceInterceptor(),
                                                     new[] {new NullInterceptionBehaviour()});
            tester.Stop();
            tester.Start("InterfaceInterceptedSecond");
            var interceptor2 = Intercept.ThroughProxy(typeof (IRuntimeType), realProxy as IRuntimeType, new InterfaceInterceptor(),
                                                      new[] {new NullInterceptionBehaviour()});

            tester.Stop();
            tester.Start("as KnownType");
            var known = interceptor as IKnownType;
            tester.Stop();
            tester.Start("KnownDo");
            known.KnownDo();
            tester.Stop();
            tester.Start("KnownDoSecond");
            known.KnownDo();
            tester.Stop();
            tester.Start("KnownDo1");
            known.KnownDo1(0, "");
            tester.Stop();
            return interceptor as IKnownType;
        }
예제 #13
0
 private static IKnownType CreateRealProxy(FirstCallTester tester)
 {
     tester.Start("RealProxy");
     var realProxy = new RealProxyProxy().GetTransparentProxy();
     tester.Stop();
     tester.Start("RealProxySecond");
     var realProxy2 = new RealProxyProxy().GetTransparentProxy() as IRuntimeType;
     tester.Stop();
     tester.Start("as KnownType");
     var known = realProxy as IKnownType;
     tester.Stop();
     tester.Start("RealProxyKnownDo");
     known.KnownDo();
     tester.Stop();
     tester.Start("RealProxyKnownDoSecond");
     known.KnownDo();
     tester.Stop();
     tester.Start("RealProxyKnownDo1");
     known.KnownDo1(0, "");
     tester.Stop();
     return realProxy as IKnownType;
 }
예제 #14
0
        public void ThroughtputTime()
        {
            var tester1 = new FirstCallTester(Console.Out);
            var tester2 = new FirstCallTester(Console.Out);

            var real = CreateRealProxy(tester1);
            var unity = CreateUnityInerceptor(tester2);

            SpeedTesting.Do(Console.Out,5,10000,(r)=> RealTime(r,real),(r) => UnityTime(r,unity));
        }