原来的序列化使用微软的。可是接口、内部类无法序列化,根本没法用。
后来使用了自己的xml技术+反射,可是性能非常的垃圾。
于是用了1天时间写了个emit框架,性能大幅度提升!
对比结果:
public void test002()
{
MyPojo2 pojo = CreateMyPojo();
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = Pixysoft.IO.XmlExporter.Instance.XmlSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = XmlManager.Serialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = XmlManager.DynamicSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = DirectSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
}
{
MyPojo2 pojo = CreateMyPojo();
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = Pixysoft.IO.XmlExporter.Instance.XmlSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = XmlManager.Serialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = XmlManager.DynamicSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
StartTest("Begin CreateObjectUsingReflection");
for (int i = 0; i < 50000; i++)
{
object content = DirectSerialize(pojo);
}
EndTest("Begin CreateObjectUsingReflection");
}