CopyPastehas never been so tasty!

ServiceStack.Text vs MS Javascript Serializer

by developer

  • 0
  • 0
  • 2
356 views

 I did a benchmark with the code below..And guess the result? (it is at the bottom)

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
   int times = int.Parse(txtNumberOfTimes.Text);
   Random random = new Random();
   
   var startMSJson = Stopwatch.StartNew();
 
   for (int i = 0; i < times;i++ )
   {
       var testObject = new { Name = "Cengiz" + i.ToString(), Surname = "Poyraz" + i.ToString() };
       var temp = new JavaScriptSerializer().Serialize(testObject);
   }
   startMSJson.Stop();
 
   txtJsonResult.Text = "Javascript Serializer : " + startMSJson.ElapsedMilliseconds.ToString() + " ms" +
                        Environment.NewLine;
 
   var startSSTJson = Stopwatch.StartNew();
 
   for (int i = 0; i < times; i++)
   {
       var testObject = new { Name = "Cengiz" + i.ToString(), Surname = "Poyraz" + i.ToString() };
       var temp = JsonSerializer.SerializeToString(testObject);
   }
   startSSTJson.Stop();
 
   txtJsonResult.Text += "ServiceStackText Serializer : " + startSSTJson.ElapsedMilliseconds.ToString() + " ms" +
                        Environment.NewLine;
 

 

Comments

  • ohhshit
    ohh realy? it's so impressive!!
  • developer
    when times = 1,000,000, the result is ;
    MS Javascript Serializer : 6922 ms
    ServiceStack.Text Serializer : 1889 ms
    
    IMPRESSIVE...

Add A Comment: