static void Main(string[] args) { DateTime now = DateTime.Now; Bank b = new Bank(); // Time 10000 payments for (int i = 0; i < 10000; i++) { Payment p = new Payment(); p.Payee = "Amazon"; p.Payer = "Bill Smith"; p.Amount = i; p.Date = "08/10/08"; p.Description = "A book"; MemoryStream ms = new MemoryStream(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(Payment)); xmlSerializer.Serialize(ms,p); // formatter.Serialize(ms, p); PaymentResponse returnMs = b.Pay(ms); } Console.WriteLine("Total time: {0}", DateTime.Now - now); Console.ReadLine(); }
static void Main(string[] args) { XmlSerializer serPayment = new XmlSerializer(typeof(Payment)); XmlSerializer serResponse = new XmlSerializer(typeof(PaymentResponse)); //IFormatter serPayment = new SoapFormatter(); //IFormatter serResponse = serPayment; Bank b = new Bank(); // Time 10000 payments DateTime now = DateTime.Now; for (int i = 0; i < 10000; i++) { Payment p = new Payment(); p.Payee = "Amazon"; p.Payer = "Bill Smith"; p.Amount = i; p.Date = "08/10/08"; p.Description = "A book"; // Convert the object and put into memorystream MemoryStream ms = new MemoryStream(); serPayment.Serialize(ms, p); MemoryStream msresp = b.Pay(ms) ; msresp.Seek(0,SeekOrigin.Begin) ; // Move the stream pointer to the front PaymentResponse resp = (PaymentResponse)serResponse.Deserialize(msresp); } Console.WriteLine("Total time: {0}", DateTime.Now - now); Console.ReadLine(); }