NLiteMapper与EmitMapper性能简单比较
应 风云(老看成 云风)要求,简单测试了下NLiteMapper的性能,顺道与Emit方式作一下性能比较,不知道是我应用不得当还是有什么其它原因,不知道为什么NLite性性能较之EmitMapper如如此大的差别,看看我的测试代码:
static void Main(string[] args)
{
//consturct data
List<SimpleClassFrom> fromCollection = new List<SimpleClassFrom>();
int count = 10000;
for (int i = 0; i < count; i++)
{
SimpleClassFrom from = new SimpleClassFrom
{
ID = 123456,
Name = "test",
Age = 30,
Email = "hhhhhhhhhhhhhhh@hotmail.com"
};
fromCollection.Add(from);
}
//test nlite mapper
NLite.Mapping.IMapper<SimpleClassFrom, SimpleClassTo> a = NLite.Mapper.CreateMapper<SimpleClassFrom, SimpleClassTo>();
Stopwatch sw = Stopwatch.StartNew();
sw.Start();
for (int i = 0; i < count; i++)
{
a.Map(fromCollection[i]);
}
sw.Stop();
Console.WriteLine("nlitemapper elapsed:{0}ms", sw.ElapsedMilliseconds);
//test emit mapper
EmitMapper.ObjectsMapper<SimpleClassFrom,SimpleClassTo> mapper = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper<SimpleClassFrom, SimpleClassTo>();
sw.Restart();
for (int i = 0; i < count; i++)
{
mapper.Map(fromCollection[i]);
}
sw.Stop();
Console.WriteLine("emitmapper elapsed:{0}ms", sw.ElapsedMilliseconds);
Console.Read();
}
我只mapper了10000个对象,看看测试结果
测试结果:
NLite Mapper具体实现我没看,有空看看,风云说是用Emit方式实现Mapper,性能不至于差如此之远!
Author:repository
From: http://repository.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
From: http://repository.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。