Spring.Aop/Aop/Framework/ProxyConfig instantiation optimization

This commit is contained in:
bbaia
2009-10-17 12:52:56 +00:00
parent 4890f7f580
commit 52f4cf7ff2
2 changed files with 32 additions and 6 deletions

View File

@@ -21,10 +21,12 @@
#region Imports
using System;
using System.Text;
using System.Text;
using System.Reflection;
using Spring.Aop.Framework.DynamicProxy;
using Spring.Core.TypeResolution;
using Spring.Util;
using Spring.Util;
using Spring.Reflection.Dynamic;
#endregion
@@ -50,16 +52,22 @@ namespace Spring.Aop.Framework
[Serializable]
public class ProxyConfig
{
#region Fields
#region Fields
private static readonly ConstructorInfo cachedAopProxyFactoryCtorInfo =
typeof(ProxyConfig).Assembly.GetType("Spring.Aop.Framework.DynamicProxy.CachedAopProxyFactory", false, false).GetConstructor(Type.EmptyTypes);
private bool proxyTargetType;
private bool proxyTargetAttributes = true;
private bool optimize;
private bool frozen;
private bool frozen;
private IAopProxyFactory aopProxyFactory =
DynamicConstructor.Create(cachedAopProxyFactoryCtorInfo).Invoke(ObjectUtils.EmptyObjects) as IAopProxyFactory;
private IAopProxyFactory aopProxyFactory =
ObjectUtils.InstantiateType( typeof(ProxyConfig).Assembly, "Spring.Aop.Framework.DynamicProxy.CachedAopProxyFactory") as IAopProxyFactory;
private bool exposeProxy;
private readonly object syncRoot = new object();
#endregion
#region Properites

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Diagnostics;
using NUnit.Framework;
#endregion
@@ -39,5 +40,22 @@ namespace Spring.Aop.Framework
{
}
#if NET_2_0
[Category("Performance")]
[Test, Explicit]
public void InstantiationPerformance()
{
int iterations = 10000;
Stopwatch watch = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
{
new ProxyConfig();
}
watch.Stop();
Console.WriteLine("Instantiation time: {0}ms", watch.ElapsedMilliseconds);
}
#endif
}
}