public void ProxyPerformanceTests() { int runs = 5000000; StopWatch watch = new StopWatch(); ITestObject testObject = new ChainableTestObject(null); using (watch.Start("Naked Duration: {0}")) { for (int i = 0; i < runs; i++) { object result = testObject.DoSomething(this); } } ITestObject hardcodedWrapper = new ChainableTestObject(testObject); using (watch.Start("Hardcoded Wrapper Duration: {0}")) { for (int i = 0; i < runs; i++) { object result = hardcodedWrapper.DoSomething(this); } } PeformanceTestAopContextInterceptor interceptor = new PeformanceTestAopContextInterceptor(); ITestObject proxy = CreateProxy(testObject, interceptor, false); using (watch.Start("Proxy Duration ('ExposeProxy'==false): {0}")) { for (int i = 0; i < runs; i++) { object result = proxy.DoSomething(this); } } Assert.AreEqual(runs, interceptor.Calls); interceptor = new PeformanceTestAopContextInterceptor(); proxy = CreateProxy(testObject, interceptor, true); using (watch.Start("Proxy Duration ('ExposeProxy'==true): {0}")) { for (int i = 0; i < runs; i++) { object result = proxy.DoSomething(this); } } Assert.AreEqual(runs, interceptor.Calls); }
public void ProxyPerformanceTests() { int runs = 5000000; StopWatch watch = new StopWatch(); ITestObject testObject = new ChainableTestObject(null); using (watch.Start("Naked Duration: {0}")) { for (int i = 0; i < runs; i++) { object result = testObject.DoSomething(this); } } ITestObject hardcodedWrapper = new ChainableTestObject(testObject); using (watch.Start("Hardcoded Wrapper Duration: {0}")) { for (int i = 0; i < runs; i++) { object result = hardcodedWrapper.DoSomething(this); } } PeformanceTestAopContextInterceptor interceptor = new PeformanceTestAopContextInterceptor(); ITestObject proxy = CreateProxy(testObject, interceptor, false); using(watch.Start("Proxy Duration ('ExposeProxy'==false): {0}")) { for(int i=0;i<runs;i++) { object result = proxy.DoSomething(this); } } Assert.AreEqual(runs, interceptor.Calls); interceptor = new PeformanceTestAopContextInterceptor(); proxy = CreateProxy(testObject, interceptor, true); using(watch.Start("Proxy Duration ('ExposeProxy'==true): {0}")) { for(int i=0;i<runs;i++) { object result = proxy.DoSomething(this); } } Assert.AreEqual(runs, interceptor.Calls); }