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

To create a trace, add the following to the code where you want to start the trace:
Debug.startMethodTracing("myapp");
and then put the following when you want to stop tracing:
Debug.stopMethodTracing();
This will create a trace to the myapp.trace trace myapp.trace in the root directory of the SD card. As it is written to the SD card:
After creating the file, you will need to copy it to your computer. You can do this using adb command:
adb pull /sdcard/myapp.trace c:/my/dir/myapp.trace
Finally, run traceview , specifying the full path in the trace file:
traceview c:/my/dir/myapp.trace
I had some problems with traceview with OutOfMemory errors. I fixed this on Windows by changing the last line of traceview.bat to:
call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
at
call java -Xmx1g -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
Adding the -Xmx1g option allows traceview use more memory.
Dave Webb Dec 24 '09 at 8:49 2009-12-24 08:49
source share