private static void NormalSerializationTests() { //// Local variables List <long> timeElapsed = new List <long>(); int load = 10000000, count = 1; DataModel model = DataModelExtension.GenerateDataModel(load); for (int i = 0; i < count; i++) { Stopwatch watch = new Stopwatch(); watch.Start(); string s = JSONSerializationTests.NewtonSoftSerialize(model); watch.Stop(); timeElapsed.Add(watch.ElapsedMilliseconds); } Log("NewtonSoftSerialize", load, count, timeElapsed); for (int i = 0; i < count; i++) { Stopwatch watch = new Stopwatch(); watch.Start(); string s = JSONSerializationTests.fastJSONSerialize(model); watch.Stop(); timeElapsed.Add(watch.ElapsedMilliseconds); } Log("fastJSONSerialize", load, count, timeElapsed); for (int i = 0; i < count; i++) { Stopwatch watch = new Stopwatch(); watch.Start(); string s = JSONSerializationTests.ServiceStackSerialize(model); watch.Stop(); timeElapsed.Add(watch.ElapsedMilliseconds); } Log("ServiceStackSerialize", load, count, timeElapsed); for (int i = 0; i < count; i++) { Stopwatch watch = new Stopwatch(); watch.Start(); string s = JSONSerializationTests.JilSerialize(model); watch.Stop(); timeElapsed.Add(watch.ElapsedMilliseconds); } Log("JilSerialize", load, count, timeElapsed); }
private static void JsonSerializationAndPeristanceTest() { DataModel model = DataModelExtension.GenerateDataModel(3000000); string blobName = "testblob01"; JSONSerializationZipAndBlobTest jszbTest = new JSONSerializationZipAndBlobTest(); byte[] data = jszbTest.DataToMemoryStream(model); DataModel model3 = jszbTest.MemoryStreamToData(data); string etag = jszbTest.MemoryStreamToBlob(data, blobName); byte[] data2 = jszbTest.BlobToMemoryStream(blobName); DataModel model2 = jszbTest.MemoryStreamToData(data2); }