- Timestamp:
- 03/19/09 12:31:19 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Test/NewSerializationTest.cs
r1358 r1360 3 3 using System.Collections.Generic; 4 4 using System.IO; 5 using HeuristicLab.Persistence.Core; 5 6 using HeuristicLab.Persistence.Interfaces; 6 7 … … 172 173 XmlParser.ParseTypeCache(new StreamReader("test-types.xml")), 173 174 ConfigurationService.Instance.GetDefaultConfig(XmlFormat.Instance)); 174 object o = deSerializer.DeSerialize(parser); 175 Root t = CloningFactory.DefaultClone(r); 175 object o = deSerializer.DeSerialize(parser); 176 176 Console.Out.WriteLine(Util.AutoFormat(o, true)); 177 177 } … … 193 193 XmlParser.ParseTypeCache(new StreamReader("test-types.xml")), 194 194 ConfigurationService.Instance.GetDefaultConfig(XmlFormat.Instance)); 195 object o = deSerializer.DeSerialize(parser); 196 Manager n = CloningFactory.DefaultClone(m); 195 object o = deSerializer.DeSerialize(parser); 197 196 Console.Out.WriteLine(Util.AutoFormat(o, true)); 198 } 199 200 public static void SpeedTest() { 201 StorableObject storable = new StorableObject(); 202 CloneableObject cloneable = new CloneableObject(); 203 Console.Write("initializing..."); 204 storable.Init(); 205 cloneable.Init(); 206 Console.WriteLine("done"); 207 List<StorableObject> storableClones = new List<StorableObject>(); 208 List<CloneableObject> clonableClones = new List<CloneableObject>(); 209 CloningFactory cloningFactory = new CloningFactory(); 210 for (int i = 0; i < 100000; i++) { 211 Console.Write("cloning storable.. "); 212 storableClones.Add(cloningFactory.Clone(storable)); 213 Console.WriteLine(); 214 Console.Write("cloning cloneable.. "); 215 clonableClones.Add((CloneableObject)cloneable.Clone()); 216 Console.WriteLine(); 217 } 218 } 219 220 public static void SpeedTest2() { 221 Root r = new Root(); 222 r.selfReferences = new List<Root> {r, r}; 223 r.c = new Custom {r = r}; 224 r.dict.Add("one", 1); 225 r.dict.Add("two", 2); 226 r.dict.Add("three", 3); 227 228 CloneableRoot cr = new CloneableRoot(); 229 cr.selfReferences = new List<CloneableRoot> {cr, cr}; 230 cr.c = new CloneableCustom {r = cr}; 231 cr.dict.Add("one", 1); 232 cr.dict.Add("two", 2); 233 cr.dict.Add("three", 3); 234 List<Root> storableClones = new List<Root>(); 235 List<CloneableRoot> clonableClones = new List<CloneableRoot>(); 236 CloningFactory cloningFactory = new CloningFactory(); 237 238 DateTime start = DateTime.Now; 239 Console.Write("cloning storable.. "); 240 for (int i = 0; i < 100000; i++) { 241 storableClones.Add(cloningFactory.Clone(r)); 242 } 243 Console.WriteLine(new TimeSpan(DateTime.Now.Ticks - start.Ticks)); 244 245 start = DateTime.Now; 246 Console.Write("cloning storable again.. "); 247 for (int i = 0; i < 100000; i++) { 248 storableClones.Add(cloningFactory.Clone(r)); 249 } 250 Console.WriteLine(new TimeSpan(DateTime.Now.Ticks - start.Ticks)); 251 252 start = DateTime.Now; 253 Console.Write("cloning cloneable.. "); 254 for (int i = 0; i < 100000; i++) { 255 clonableClones.Add((CloneableRoot)cr.Clone(new Dictionary<object, object>())); 256 } 257 Console.WriteLine(new TimeSpan(DateTime.Now.Ticks - start.Ticks)); 258 clonableClones.Clear(); 259 260 } 197 } 261 198 262 199 public class Base {
Note: See TracChangeset
for help on using the changeset viewer.