private static void cache() { const int HANDS_TO_CACHE = 100; Random random = new MersenneTwister(); DateTime start = DateTime.Now; List <CachedHand> cached = new List <CachedHand>(); for (int i = 0; i < HANDS_TO_CACHE; i++) { if (i % 100 == 0) { Console.WriteLine("Hand #{0}", i + 1); } cached.Add(new CachedHand(6, random)); } CachedHands hands = new CachedHands(); hands.Hands = cached; XmlSerializer ser = new XmlSerializer(typeof(CachedHands)); using (TextWriter txt = new StreamWriter("test.xml")) ser.Serialize(txt, hands); double time = DateTime.Now.Subtract(start).TotalMilliseconds; Console.WriteLine("Time: {0}", time); }
private static void cache() { const int HANDS_TO_CACHE = 100; Random random = new MersenneTwister(); DateTime start = DateTime.Now; List<CachedHand> cached = new List<CachedHand>(); for (int i = 0; i < HANDS_TO_CACHE; i++) { if (i % 100 == 0) Console.WriteLine("Hand #{0}", i + 1); cached.Add(new CachedHand(6, random)); } CachedHands hands = new CachedHands(); hands.Hands = cached; XmlSerializer ser = new XmlSerializer(typeof(CachedHands)); using (TextWriter txt = new StreamWriter("test.xml")) ser.Serialize(txt, hands); double time = DateTime.Now.Subtract(start).TotalMilliseconds; Console.WriteLine("Time: {0}", time); }