public void ReflectionPerformanceDirLandReply() { DateTime messageTestTime = DateTime.UtcNow; for (int x = 0; x < TEST_ITER; x++) { DirLandReplyMessage s = new DirLandReplyMessage(); s.AgentID = UUID.Random(); s.QueryID = UUID.Random(); s.QueryReplies = new DirLandReplyMessage.QueryReply[2]; DirLandReplyMessage.QueryReply q1 = new DirLandReplyMessage.QueryReply(); q1.ActualArea = 1024; q1.Auction = true; q1.ForSale = true; q1.Name = "For Sale Parcel Q1"; q1.ProductSku = "023"; q1.SalePrice = 2193; q1.ParcelID = UUID.Random(); s.QueryReplies[0] = q1; DirLandReplyMessage.QueryReply q2 = new DirLandReplyMessage.QueryReply(); q2.ActualArea = 512; q2.Auction = true; q2.ForSale = true; q2.Name = "For Sale Parcel Q2"; q2.ProductSku = "023"; q2.SalePrice = 22193; q2.ParcelID = UUID.Random(); s.QueryReplies[1] = q2; OSDMap map = s.Serialize(); DirLandReplyMessage t = new DirLandReplyMessage(); t.Deserialize(map); Assert.AreEqual(s.AgentID, t.AgentID); Assert.AreEqual(s.QueryID, t.QueryID); for (int i = 0; i < s.QueryReplies.Length; i++) { Assert.AreEqual(s.QueryReplies[i].ActualArea, t.QueryReplies[i].ActualArea); Assert.AreEqual(s.QueryReplies[i].Auction, t.QueryReplies[i].Auction); Assert.AreEqual(s.QueryReplies[i].ForSale, t.QueryReplies[i].ForSale); Assert.AreEqual(s.QueryReplies[i].Name, t.QueryReplies[i].Name); Assert.AreEqual(s.QueryReplies[i].ProductSku, t.QueryReplies[i].ProductSku); Assert.AreEqual(s.QueryReplies[i].ParcelID, t.QueryReplies[i].ParcelID); Assert.AreEqual(s.QueryReplies[i].SalePrice, t.QueryReplies[i].SalePrice); } } TimeSpan duration = DateTime.UtcNow - messageTestTime; Console.WriteLine("DirLandReplyMessage: OMV Message System Serialization/Deserialization Passes: {0} Total time: {1}", TEST_ITER, duration); BinaryFormatter formatter = new BinaryFormatter(); DateTime xmlTestTime = DateTime.UtcNow; for (int x = 0; x < TEST_ITER; x++) { DirLandReplyMessage s = new DirLandReplyMessage(); s.AgentID = UUID.Random(); s.QueryID = UUID.Random(); s.QueryReplies = new DirLandReplyMessage.QueryReply[2]; DirLandReplyMessage.QueryReply q1 = new DirLandReplyMessage.QueryReply(); q1.ActualArea = 1024; q1.Auction = true; q1.ForSale = true; q1.Name = "For Sale Parcel Q1"; q1.ProductSku = "023"; q1.SalePrice = 2193; q1.ParcelID = UUID.Random(); s.QueryReplies[0] = q1; DirLandReplyMessage.QueryReply q2 = new DirLandReplyMessage.QueryReply(); q2.ActualArea = 512; q2.Auction = true; q2.ForSale = true; q2.Name = "For Sale Parcel Q2"; q2.ProductSku = "023"; q2.SalePrice = 22193; q2.ParcelID = UUID.Random(); s.QueryReplies[1] = q2; MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, s); stream.Seek(0, SeekOrigin.Begin); DirLandReplyMessage t = (DirLandReplyMessage)formatter.Deserialize(stream); Assert.AreEqual(s.AgentID, t.AgentID); Assert.AreEqual(s.QueryID, t.QueryID); for (int i = 0; i < s.QueryReplies.Length; i++) { Assert.AreEqual(s.QueryReplies[i].ActualArea, t.QueryReplies[i].ActualArea); Assert.AreEqual(s.QueryReplies[i].Auction, t.QueryReplies[i].Auction); Assert.AreEqual(s.QueryReplies[i].ForSale, t.QueryReplies[i].ForSale); Assert.AreEqual(s.QueryReplies[i].Name, t.QueryReplies[i].Name); Assert.AreEqual(s.QueryReplies[i].ProductSku, t.QueryReplies[i].ProductSku); Assert.AreEqual(s.QueryReplies[i].ParcelID, t.QueryReplies[i].ParcelID); Assert.AreEqual(s.QueryReplies[i].SalePrice, t.QueryReplies[i].SalePrice); } } TimeSpan durationxml = DateTime.UtcNow - xmlTestTime; Console.WriteLine("DirLandReplyMessage: .NET BinarySerialization/Deserialization Passes: {0} Total time: {1}", TEST_ITER, durationxml); }
public void ReflectionPerformanceDirLandReply2() { XmlSerializer xmlSerializer = new XmlSerializer(typeof(DirLandReplyMessage)); DirLandReplyMessage s = new DirLandReplyMessage(); s.AgentID = UUID.Random(); s.QueryID = UUID.Random(); s.QueryReplies = new DirLandReplyMessage.QueryReply[2]; DirLandReplyMessage.QueryReply q1 = new DirLandReplyMessage.QueryReply(); q1.ActualArea = 1024; q1.Auction = true; q1.ForSale = true; q1.Name = "For Sale Parcel Q1"; q1.ProductSku = "023"; q1.SalePrice = 2193; q1.ParcelID = UUID.Random(); s.QueryReplies[0] = q1; DirLandReplyMessage.QueryReply q2 = new DirLandReplyMessage.QueryReply(); q2.ActualArea = 512; q2.Auction = true; q2.ForSale = true; q2.Name = "For Sale Parcel Q2"; q2.ProductSku = "023"; q2.SalePrice = 22193; q2.ParcelID = UUID.Random(); s.QueryReplies[1] = q2; System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); for (int i = 0; i < TEST_ITER; ++i) { MemoryStream stream = new MemoryStream(); OSDMap map = s.Serialize(); byte[] jsonData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(map)); stream.Write(jsonData, 0, jsonData.Length); stream.Flush(); stream.Close(); } timer.Stop(); Console.WriteLine("OMV Message System Serialization/Deserialization Passes: {0} Total time: {1}", TEST_ITER, timer.Elapsed.TotalSeconds); timer.Reset(); timer.Start(); for (int i = 0; i < TEST_ITER; ++i) { MemoryStream stream = new MemoryStream(); xmlSerializer.Serialize(stream, s); stream.Flush(); stream.Close(); } timer.Stop(); Console.WriteLine(".NET BinarySerialization/Deserialization Passes: {0} Total time: {1}", TEST_ITER, timer.Elapsed.TotalSeconds); }
public void DirLandReplyMessage() { DirLandReplyMessage s = new DirLandReplyMessage(); s.AgentID = UUID.Random(); s.QueryID = UUID.Random(); s.QueryReplies = new DirLandReplyMessage.QueryReply[2]; DirLandReplyMessage.QueryReply q1 = new DirLandReplyMessage.QueryReply(); q1.ActualArea = 1024; q1.Auction = true; q1.ForSale = true; q1.Name = "For Sale Parcel Q1"; q1.ProductSku = "023"; q1.SalePrice = 2193; q1.ParcelID = UUID.Random(); s.QueryReplies[0] = q1; DirLandReplyMessage.QueryReply q2 = new DirLandReplyMessage.QueryReply(); q2.ActualArea = 512; q2.Auction = true; q2.ForSale = true; q2.Name = "For Sale Parcel Q2"; q2.ProductSku = "023"; q2.SalePrice = 22193; q2.ParcelID = UUID.Random(); s.QueryReplies[1] = q2; OSDMap map = s.Serialize(); DirLandReplyMessage t = new DirLandReplyMessage(); t.Deserialize(map); Assert.AreEqual(s.AgentID, t.AgentID); Assert.AreEqual(s.QueryID, t.QueryID); for (int i = 0; i < s.QueryReplies.Length; i++) { Assert.AreEqual(s.QueryReplies[i].ActualArea, t.QueryReplies[i].ActualArea); Assert.AreEqual(s.QueryReplies[i].Auction, t.QueryReplies[i].Auction); Assert.AreEqual(s.QueryReplies[i].ForSale, t.QueryReplies[i].ForSale); Assert.AreEqual(s.QueryReplies[i].Name, t.QueryReplies[i].Name); Assert.AreEqual(s.QueryReplies[i].ProductSku, t.QueryReplies[i].ProductSku); Assert.AreEqual(s.QueryReplies[i].ParcelID, t.QueryReplies[i].ParcelID); Assert.AreEqual(s.QueryReplies[i].SalePrice, t.QueryReplies[i].SalePrice); } }