Servicestack.text/newtonsoft.json of two Json serialization performance comparisons

Source: Internet
Author: User

JSON serialization is now very much used, especially in the case of a front-end separation, most of the common C # Under the use of Newtonsoft.json to operate, a small amount of cases, but also can be ignored, but the large amount of case to consider the use of Servicestack.text to operate, the serialization performance is similar, the deserialization performance is about one times higher

intCount =10000; User User=NewUser () {Id =1, Name ="Tyh", Addtime = DateTime.Now, age = the, Status =true };stringtemp =String.Empty; User User1=NewUser ();stringTemp1 ="{\ "id\": \ "2\", \ "name\": \ "xxc\", \ "addtime\": \ "2016-09-07 10:10:10\", \ "age\": \ "15\", \ "status\": \ "true\"}"; Stopwatch SW=NewStopwatch (); SW. Restart (); for(inti =0; I < count; i++) {Temp=ServiceStack.Text.JsonSerializer.SerializeToString (user);} Sw. Stop (); Response.Write ("Servicestack-ser:"+ SW. Elapsedmilliseconds +"</br>"); SW. Restart (); for(inti =0; I < count; i++) {User1= servicestack.text.jsonserializer.deserializefromstring<user>(TEMP1);} Sw. Stop (); Response.Write ("Servicestack-des:"+ SW. Elapsedmilliseconds +"</br>"); SW. Restart (); for(inti =0; I < count; i++) {Temp=Newtonsoft.Json.JsonConvert.SerializeObject (user);} Sw. Stop (); Response.Write ("Newtonsoft-ser:"+ SW. Elapsedmilliseconds +"</br>"); SW. Restart (); for(inti =0; I < count; i++) {User1= newtonsoft.json.jsonconvert.deserializeobject<user>(TEMP1);} Sw. Stop (); Response.Write ("Newtonsoft-des:"+ SW. Elapsedmilliseconds +"</br>"); Response.End ();

Here is the test results, I only cut one diagram, other self-test it

Servicestack.text/newtonsoft.json of two Json serialization performance comparisons

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.