void Start() { //BaseClass ba = new BaseClass(); SerTest st2 = new SerTest(1000, 5000f, 1000f, 1000f); //string path = "D:\\Desktop\\1.bin"; //BinarySerializeHelper.InstanceDataToFile(st2, path); //SerTest mc = BinarySerializeHelper.FileToInstanceData<SerTest>(path); mc.Print(); //MemoryStream stram = BinarySerializeHelper.InstanceDataToMemory(st2); //SerTest m0 = BinarySerializeHelper.MemoryToInstanceData<SerTest>(stram, 0);m0.Print(); //SoapSerializeHelper.InstanceDataToFile(st2, path); //SerTest mc1 = BinarySerializeHelper.FileToInstanceData<SerTest>(path); mc1.Print(); //MemoryStream stram1 = BinarySerializeHelper.InstanceDataToMemory(st2); //SerTest m01 = BinarySerializeHelper.MemoryToInstanceData<SerTest>(stram1, 0); m01.Print(); /* 测试 集合 */ ClassCollection cc1 = new ClassCollection(); // 第一种 字段全为null MemoryStream temp = BinarySerializeHelper.InstanceDataToMemory(cc1); Debug.Log(temp.Length); ClassCollection cc2 = BinarySerializeHelper.MemoryToInstanceData <ClassCollection>(temp, 0); cc2.Print(); Debug.Log("---------------------"); // 第二种 正常 List <SerTest> list = new List <SerTest>(); Dictionary <string, SerTest> dict = new Dictionary <string, SerTest>(); Stack <SerTest> stack = new Stack <SerTest>(); Queue <SerTest> queue = new Queue <SerTest>(); list.Add(st2); dict.Add("1", st2); stack.Push(st2); queue.Enqueue(st2); ClassCollection cc3 = new ClassCollection(list, dict, stack, queue); cc3.Myfloat = 0.9f; MemoryStream temp2 = BinarySerializeHelper.InstanceDataToMemory(cc3); Debug.Log("**"); Debug.Log(temp2.Length); ClassCollection cc4 = BinarySerializeHelper.MemoryToInstanceData <ClassCollection>(temp2, 0); cc4.PrintDetail(); Debug.Log(cc4.x); Debug.Log(cc4.Myfloat); }
public static void Test10(DniproDB db) { SerTest st = new SerTest(); st.Arr = new List<int>(); for (int i = 0; i < 100; i++) { st.Arr.Add(i); } string str = "";// = Serialization.Serialize(st); int code = 0; //insert pages with comments; Stopwatch s = new Stopwatch(); s.Start(); for (int i = 0; i < 100000; i++) { code += Serialization.DeserializeProxy<SerTest>(new SerTest(), str).GetHashCode(); //code += Serialization.Deserialize<SerTest>(str).GetHashCode(); } s.Stop(); Console.WriteLine("Inserts: " + s.ElapsedMilliseconds.ToString()); }