Performance testing of Android app - android

I have developed an app which make connection to MySQL database and display some information from there. Is there a way to test performance of app like simulation of different amount of users request.
500 HTTP requests
1000, 1500 request.

Yes it is possible ... Performance Testing a Mobile Application is different from server or other applications.
Simulating the load can be done by pushing dummy records to SQLite Table and doing your testing. However, Since you mentioned that
app which make connection to MySQL database and display some information from there
I would like to suggest you to look for the following.
Analyze the data parsing logic and how the data is rendered on device.
Data Retrieval Thread should be separate from Main Thread.
Data Parsing should occur in parts. User should not wait for all 500 records to be parsed before rendering on screen. To do this, in the code, based on device screen size data retrieval count should be managed.
What are the views used to render the data on screen ? If list View, see how the data is getting recycled.
In SQLite, if they are storing images, see if BLOB datatype is used.
Check the frequency of database interaction. This would impact the application performance highly.
Hope this helps.

Try with JMeter. It's free tool. I've been using it to simulate http request to pages. Hope its help.

Related

Web server best practices

I need a suggestion on a design decision.
I am creating a ecommmerce app and have a lot of items (>10000) to show in my app. Now here are the 2 options I have
1) Get all the items information from the server and save in local db and synchronize the information every time (let say 15 min)
2) Get the information every time from the web server (through rest api).
There are pros and cons of both the methods. Using local db I can get fast results and less server bandwidth but will have to handle synchronization
With second approach, I will have a lot of server request to and free and load on server.
I would also like to know how does other apps like amazon and flipkart handle this. Do they save in local db or request server every time.
What you should be looking for is a mixed design between local and remote.
In terms of data types there are two major types:
blobs 'binary large objects' for example: images, videos ...
and small data (usually json/xml representation of the items).
Amazon and other web apps provide fresh data every time the app loads, and at the same time keeps a local copy of the data incase the app went offline, or sometimes even use that data in the next load while waiting for the backend.
On the other end those app maintain a cache level for large data so that they don't have to load it more than once.
But the key for this to work is to have a very fast backend that contains many features to improve its speed including:
cloud front end that allows users to communicate with the closest server around them.
memcached or any other caching technology that will keep the info about the items in the RAM in the servers and not having to query the database to get them.
what usually happens is that the backend ensures that its data always loaded in the ram/cache by ether querying the database every specific time or by pushing to cache every time an insert/delete/update happened to the database.
Here is how Twitter is doing it
One last note Your app shouldn't take longer to interact with more than a web page, its not acceptable for native apps to take longer than web apps to allow the user to interact with them.
Only load what you want to show, but cache intelligently.
For example; an image for a product isn't going to change very often, but the amount of items available for a very popular item can change every second. Decide on a case by case basis what piece of information to refresh and when.
You definitely don't want to pull down everything from your server every time someone launches the app. That does not result in lower bandwidth. It will melt your server, eat up their data plan, and fill their phone storage with products that they will never see.

Persisting ListView

I'm building a listview and getting it's data from Parse.com. At the moment, every time the app loads up it queries for new data from Parse.com, causing the whole listview to load.
I'd like a situation where the listview references a local datasource and only go to Parse.com if new data is available. Somewhat similar to what the instagram app does whereby when you load it up, the list view is already populated and would get updated if needed.
I have tried ParseQuery Cache policies but the behavior still stays the same. What would be the most efficient way of implementing this feature?
Thanks in advance.
Sync Adapters can help you with your your problem. It is generally used for account and cloud synchronization. But there is no limitation using it.
http://developer.android.com/training/sync-adapters/index.html
Synchronizing data between an Android device and web servers can make
your application significantly more useful and compelling for your
users. For example, transferring data to a web server makes a useful
backup, and transferring data from a server makes it available to the
user even when the device is offline. In some cases, users may find it
easier to enter and edit their data in a web interface and then have
that data available on their device, or they may want to collect data
over time and then upload it to a central storage area.
Although you can design your own system for doing data transfers in
your app, you should consider using Android's sync adapter framework.
This framework helps manage and automate data transfers, and
coordinates synchronization operations across different apps. When you
use this framework, you can take advantage of several features that
aren't available to data transfer schemes you design yourself
You can access sample project here: http://developer.android.com/shareables/training/BasicSyncAdapter.zip
Note: Sync adapters run asynchronously, so you should use them with the
expectation that they transfer data regularly and efficiently, but not
instantaneously. If you need to do real-time data transfer, you should
do it in an AsyncTask or an IntentService.

How to store data on android for fast retrieval

I am trying to write an application that retrieves data that the user has stored. Whats the best way to store this data. The data has a large number of rows but each field has very little data. Initially I was thinking of using Sqlite , but the read calls I believe are very slow and need to be implement in a background thread according to Vogella's thread.
I need extremely quick retrieval rate.
Are there any other option for me?
SQLite is not slow. It's practically immediate for my quiz app with thousands of entries.
Read this for the options and details on them.

providing a web service: what are best practices for splitting JSON data into two datasets?

I have a database and I need to present a data via HTTP using JSON web services. Currently, I'm designing JSON datasets that will be provided as web services. The data from the tables will be aggregated to suite an app needs.
If the data size is large and we will try to download that at once then it might take too much time and an app will not be responsive at start. That's bad. It's well known we should minimize the number of http requests the app will make to download the data. However if we would split the data into small chunks then during every app action step an app will performe http requests and that might be unresponsive solution too.
We are talking here about mobile app development, so internet will be exposed over cellular ISP or wifi, so the speed might be quite slow. I understand the split process depends on app workflow process and etc., just curious are there any general guidelines? For example: if JSON data is larger than 1MB then definitely split it into smaller chunks...
Look at how your mail read work. You probably have tens of thousands of emails in your account. The app will show the first ones then provide a button at the bottom of the list to display more items. It's a pretty good solution usually to provide a lot of data.
Also #Selvin ideas are just great. Don't use UI thread to download stuff, use a different thread. Services are pretty good for getting data asynchronously.
One of the way is to create a service which gets started when there is network. All downloaded data can be cached in sqlite and use a content provider to get the data. But it depends on your app.
Sometimes it depends on your UI Screen. For eg. You can create a Listview with load more. On click of it load extra data.
Other way is to create API such as which gives only updates based on timestamp. But its all depends on the app. Just sharing my ideas. Might not be perfect. Others can surely give a better one.

How to achieve pagination?

I am dealing with huge data (downloading from webserver to client/phone). Currently I am trying to parse and load complete data into sqlite database when the application launches.
This is taking a lot of time. I want to load the data based on the screen navigation.
How do I achieve that?
You'll want to pass information between your server and the device as XML.
This way the device can request URLs for specific information such as example.com/news/latest (return headlines of the latest 20 news articles), example.com/news/americas (the latest 20 article headlines from the Americas) or example.com/news/article/177309/ (one full article).
The server can then query its database for the needed information based on the query and output it for the client as XML. The client can parse the XML and add the data to it's local SQLiteDatabase.
Is this not restricting the dataset returned from the source first, then downloading it onto the client device?
If you are looking for performance boost up , i prefer running an async task in which the data gets uploaded or downloaded to the server. Its similar to threads but much better.

Categories

Resources