简体   繁体   中英

Give me a suggestion to improve my app performance, on retrieving huge data(nearly more than 10,000 records) from server?

从性能角度来看,JSON解析需要大量时间来检索数据。在我的应用中,我需要从Server中获取近10,000条记录。在模拟器上,它可以立即获取数据并有效地工作。但是在我的android手机中,它需要2分钟以上的时间才能完成检索所有数据。请给我一个改善手机性能的建议。

The emulator has access to your host machine's resources and is therefore not a good way to test performance.

I have used the Jackson streaming JSON parser with large data sets and it works well for me. However, I run this process in the background and am able to accept long fetch/parse times. Depending on the size of the data and the speed of the device you're running on, 2 minutes does not seem extraordinarily long to me.

Maybe you could fetch a smaller subset of the data first, and then display it while you fetch the rest in the background. You're probably going to have to do some kind of optimization like this in order to improve performance.

I think you can parse the complex JSON response using GSON. Please check these tutorial http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html

You just create the model classes and use the proper annotations then the data will be parsed to model objects directly.

The question is, what causes this slowdown. Because of everything goes in the rmulator like charm, it is probably the network speed. You can help this if you find a solution to compress the json data.

It is a text, with a lot of repeat, it is very, very good compressable. And http supports compression.

You need to set it in your http server.

If you find this a promising direction, I suggest to make a new question, giving your http server version. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM