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); }
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); }
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)"))); }
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)); }
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)"))); }
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 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); }
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(); }
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(); }
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); }
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; }
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; }
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)); }