开发者

SAX parser takes a lot of time to parse

开发者 https://www.devze.com 2023-03-18 08:50 出处:网络
I have created an application where I parse data from server using SAX parser. I followed this link It works 开发者_运维百科fine but it took a lot of time. I need to reduce time taken to parse stuff

I have created an application where I parse data from server using SAX parser. I followed this link

It works 开发者_运维百科fine but it took a lot of time. I need to reduce time taken to parse stuff. Any pro-tips?


The obvious tip is: profile your code and determine where the time is going. Perhaps you are doing a lot of work handling some of the SAX events. Perhaps the time is being spent doing something entirely unrelated to the parsing. You can't tell until you profile.


Like Ted said, profile your code.

Are you sure its the parse time and not the load time? Are you on wifi or a mobile network? How quickly are other apps loading their data?

That said, don't use that many ArrayList objects, a single array list with a custom container type (i.e. a Ticket object has a price and date, no need to have a price array and date array).

Check you memory usage, usually if things are slow you are generating a ton of garbage. (look for the GC in the log)

Use the final keyword for String parameters that won't change. So setString(final String s) instead of setString(String s). This should prevent the Strings from being duplicated when passed as parameters.

Use JSON instead of XML if you can, its more light weight.

After you've made any significant change, profile your code again

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号