Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test the performance of an Android application?

How can I test an application for performance in Android? What is the support provided in Android and how do I use it?

like image 878
Bharat Pawar Avatar asked Dec 24 '09 06:12

Bharat Pawar


People also ask

How do you manually test a mobile app?

You can perform mobile application manual testing using emulators or simulators and by choosing the desired device. You can also perform mobile application manual testing using real device cloud or setting up a device lab within your organization.

How do I test an APK file?

Since APK files come in compressed ZIP format, any ZIP decompression tool can open it. So, for viewing the contents of an APK file, all you have to do is rename its extension to . zip and open it. Or, you can open it directly through an open dialogue box of a zip application.


1 Answers

If you want to profile your application to find performance bottlenecks you can use the traceview tool. This gives you a graphical view of performance traces of your application.

To create a trace add the following to your code where you want to start tracing:

Debug.startMethodTracing("myapp"); 

and then put the following when you want to stop tracing:

Debug.stopMethodTracing(); 

This will create a trace file call myapp.trace in the root directory of the SD Card. As it is written to the SD Card:

  • If you're using the emulator you'll need to add an SD card to your AVD.
  • You'll need to give you app permission to write the SD card by adding the following to your Manifest:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Once the file has been created you'll need to copy it to your PC. You can do this using the adb command:

adb pull /sdcard/myapp.trace c:/my/dir/myapp.trace 

Finally, start traceview giving it the full path to the trace file:

traceview c:/my/dir/myapp.trace 

I did have some problems with traceview failing with OutOfMemory exceptions. I fixed this on Windows by changing the last line of traceview.bat from:

call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %* 

to:

call java -Xmx1g -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %* 

Adding the -Xmx1g option allows traceview to use more memory.

like image 60
Dave Webb Avatar answered Sep 26 '22 23:09

Dave Webb