代码拉取完成,页面将自动刷新
同步操作将从 懒得勤快/Masuit.Tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using AutoMapper;
using Masuit.Tools.Mapping;
using Masuit.Tools.Systems;
using System;
using System.Collections.Generic;
namespace Masuit.Tools.ExpressionMapperBenchmark
{
class Program
{
static void Main(string[] args)
{
#region 配置automapper
var mapper = new MapperConfiguration(e =>
{
e.CreateMap<TestClassA, TestClassB>().ReverseMap();
e.CreateMap<TestClassC, TestClassD>().ReverseMap();
}).CreateMapper();
#endregion
#region 配置ExpressionMapper
ExpressionMapper.CreateMap<TestClassA, TestClassB>().ReverseMap();
ExpressionMapper.CreateMap<TestClassC, TestClassD>().ReverseMap();
#endregion
#region 造一个大对象
var a = new TestClassA()
{
MyProperty = "ssssssssssssssssssssss",
DateTime = DateTime.Now,
Double = 123.33,
Int = 100,
TestClassC = new TestClassC()
{
MyProperty = "ccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddd",
Obj = new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 23458894.555,
Int = 10100000,
Obj = new TestClassD()
}
}
},
List = new List<TestClassC>()
{
new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddddddddddddd",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassC()
{
MyProperty = "cccccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
}
}
},
new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddddddddddddd",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassC()
{
MyProperty = "cccccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
}
}
},
new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddddddddddddd",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassC()
{
MyProperty = "cccccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
}
}
},
new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddddddddddddd",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassC()
{
MyProperty = "cccccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
}
}
},
new TestClassC()
{
MyProperty = "cccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
{
MyProperty = "ddddddddddddddddddddddddddddddddddd",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassC()
{
MyProperty = "cccccccccccccccccccccccccccccc",
DateTime = DateTime.Now,
Double = 2345.555,
Int = 10100,
Obj = new TestClassD()
}
}
},
}
};
#endregion
var time = HiPerfTimer.Execute(() =>
{
a.Map<TestClassA, TestClassB>();
a.Map<TestClassA, TestClassB>();
});
Console.WriteLine($"ExpressionMapper映射2次耗时:{time}s");
time = HiPerfTimer.Execute(() =>
{
for (int i = 0; i < 1000000; i++)
{
var b = a.Map<TestClassA, TestClassB>();
}
});
Console.WriteLine($"ExpressionMapper映射100000次耗时:{time}s");
time = HiPerfTimer.Execute(() =>
{
mapper.Map<TestClassB>(a);
mapper.Map<TestClassB>(a);
});
Console.WriteLine($"AutoMapper映射2次耗时:{time}s");
time = HiPerfTimer.Execute(() =>
{
for (int i = 0; i < 1000000; i++)
{
var b = mapper.Map<TestClassB>(a);
}
});
Console.WriteLine($"AutoMapper映射100000次耗时:{time}s");
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。