How can I test an application for performance in Android? What is the support provided in Android and how do I use it?
5 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.

- 1
- 1

- 190,537
- 57
- 313
- 299
-
Is there some way to get info like responsiveness,launch latency,CPU cycles used by an application – Bharat Pawar Jan 20 '10 at 05:44
-
1I wonder if you guys use TraceView alone for UI performance benchmarks, or if you actually automate it, for example combined with the Robotium test framework (robotium.org). Any 'best practices' in that regard? – Mathias Conradt Oct 11 '10 at 02:10
-
Can you view the trace in realtime, without the need to copy the file? – AlikElzin-kilaka Jul 30 '12 at 14:29
-
size of myapp.trace is 0 . why? – CooL i3oY Sep 11 '12 at 05:28
-
why not use it from eclipse DDMS? – Nativ Apr 21 '13 at 11:32
-
1Mentioned link was dead.. Updated: https://developer.android.com/studio/profile/traceview.html – Shailendra Madda Feb 22 '17 at 10:37
-
As in https://developer.android.com/studio/profile/generate-trace-logs.html Logs will be saved at /sdcard/Android/data/package/files/myapp.trace – M at Apr 18 '18 at 09:27
Also, theoretically, DDMS can get memory allocations for your program and then you can analyze the dump using profilers.
DDMS Reference.
The reason why I have theoretically in italics is that I myself have not tried doing anything such, yet.

- 36,316
- 26
- 109
- 116
-
1⚠️ Dalvik Debug Monitor Server (DDMS) - This tool is deprecated. —— https://developer.android.com/studio/profile/monitor – Pang Sep 28 '18 at 08:20
I think traceView contains too much information, you can easily get lost.
My solution is just log the system time at three place in the code.
Before and after and center at the potiential slow code.
like binary search, next time, narrow it down step by step, then finally find the culprit code.

- 1,376
- 11
- 8
you can use load runner.,
use this link to find more about it.,
Steps to be followed are:
- Create New VuGen Script
- Select Mobile Application-HTTP/HTML
- Recording Options--> Select Record Emulator
- Give the path to Record Emulator as D:\android\AVD Manager.exe
- In the command line -avd AVD_NAME -netspeed full -netdelay none where AVD_Name is the name of your Device
- select the working directory
- click finish
Now you can perform your test.,

- 282
- 2
- 7
- 15

- 3
- 6
Another way to test is Using TruClient on Load Runner
Steps to be followed for Mobile Web are:
- New VuGen Script
- Mobile Protocol
- Select TruClient Mobile Web
- Click Create
- Now you can generate scripts
- Click Develop Script button
- PoP up window appears to select the device
- Select Actions and you can record the scripts
Steps to be followed for Native Mobile are:
- New VuGen Script
- Mobile Protocol
- Select TruClient Native Mobile
- Click Create
- Now you can generate scripts
- click develop script
- TruClient window that plugged with Firefox appears
- Click General Settings
- Configure the SERVER URL PORT
- If u don't know the server url port means install OS MONITOR application on your device. here you can find the ip address
- Enter User Name and Password
- Click done
you can record the scripts and perform your testing....

- 3
- 6