views:

46

answers:

1

Here is what I am doing currently.

  1. Get data from database in DataTable (max records would be 100 but stored proc will search against more than 500,000 records. I already took care of search optimization in database. I am looking how I can improve the performance as much as I can in step# 2 and step# 3 below.)
  2. Create a generic list (List)
  3. Use that list and passing it to JavaScriptSerializer to get JSON back.

There are couple more options to generate JSON like DataContractJsonSerializer or JSON.NET or WCF. I wanted to know which options give better performance? Or any other way I can improve the performance?

+1  A: 

Here are some perf results from the author of JSON.Net: http://james.newtonking.com/archive/2010/01/01/net-serialization-performance-comparison.aspx. The conclusion would be JSON.Net, if you care to use a third party library.

Frank Schwieterman
Thanks Frank. One thing I don't understand where that deserialization comes in picture. I am just using JavaScriptSerializer class to serialize objects.
shailesh
Well the perf results cover serialization and deserialization. If you only care about serialization it should be sufficient. That would imply some other component is doing deserialization, I couldn't tell you where that is without knowing more about the application you're working on.
Frank Schwieterman
I'd also agree with some of the other comments that this probably isn't your performance bottleneck... But JSON.Net is a good library to use either way.
Frank Schwieterman
Thanks. One more thing - As far as I know I can have ashx handler or web service or WCF that can be called from jQuery to get the data back in JSON format. Which one would you prefer ashx or WCF? Which one is light weight or can give better performance?
shailesh
Well I've used both and prefer ashx. WCF is a pain to configure and gets in the way most of the time. Using their OperationContract/WebInvoke to set up a restful service, input parameters must all be strings or lists of strings, I still have to write code to do serialization. POST parameters are still shuttled as form parameters, even if they are JSON encoded objects. Kind of yuk. An ASHX page implementation should be lightweight enough- just check the request verb, content type header, then deserialize the request body.
Frank Schwieterman