Debugging/Optimization Tools

Debugging/Optimization Tools

<p> Android Debugging/Optimization Tools By Victor Gallego</p><p>This tutorial will introduce some of the tools available in your Android SDK.</p><p>If you are using Eclipse your tools folder is found in your Android SDK folder. So if your SDK is on the root of your C: drive for example, it can be found in: C: \android-sdk-windows\tools</p><p>For those using MOTODEV Studio, your tools folder may be found in your installation folder: C:\Program Files\Motorola\MOTODEV Studio for Android 1.0.2\android-sdk- windows\tools</p><p>1. Dev Tools –Show Screen Updates</p><p>Open the Dev tools application installed on your Android emulator.</p><p>Show Screen updates</p><p>Invalidate call while performing drag and drop on an icon</p><p>The following is shown whenever a view has invoked the invalidate() method. This tool may be useful for identifying whether your application is redrawing parts of the screen unnecessarily. For the example shown above, an icon on the home screen will invalidate itself while being dragged, here it makes sense to redraw just a small portion of the screen and not the entire screen. </p><p>For more information I recommend the following link: http://developer.android.com/guide/developing/debug-tasks.html</p><p>2. Hierarchy Viewer</p><p>Typically, for optimizing your android application’s UI your goal as a developer is to make the View Hierarchy as flat as possible. As seen below in hierarchy viewer, your views are represented with a tree structured where children views are nested within their respective parent views. The layout created in XML, for instance the beginning of our main.xml starts under the FrameLayout whose id is content. We can see that can see that this particular layout consists of a LinearLayout, one TextView and three Buttons. Your XML Layout begins here</p><p>This example is not very complex, but you can imagine for more interesting layouts the hierarchy can become long if you are not careful. Long hierarchies increase the amount of time it takes to draw your layout, and so produce a less responsive UI. Long hierarchies are generally attributed to adding views groups unnecessarily for “better” placement of your widgets on the screen. </p><p>The strategy for achieving flat hierarchies is to use a RelativeLayout. RelativeLayouts allow you to define rules which place your views on the screen relative to one another or relative to one particular view. You can build very complicated layouts with RelativeLayouts without having to nest views within each other and consequently add depth to your hierarchy.</p><p>Here is a list of articles I recommend reading for more information: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html http://developer.android.com/guide/developing/tools/hierarchy-viewer.html 3. Traceview</p><p>Trace Threads timeline</p><p>Profile Panel</p><p>Usually we are only concerned with the main thread. This is the thread where the UI runs. Shown above, each method has its parents (the calling method) and children (called methods). The columns are described below:</p><p> Inc % - percentage of the total time spent in the method plus any called methods.  Inclusive – amount of time spent in the method plus the time spent in any called methods.  Excl % - percentage of the total time spent in the method.  Exclusive – amount of time spent in the method  Calls + Recursive – the number of calls to this method plus any recursive calls  Time/Call – the average amount of time per call</p><p>Note: Method tracing has huge impact on performance, so before uploading your application to the market, it is best remove all tracing code from your application.</p><p>In order to start method tracing in Android here is what is required.</p><p> Debug.startMethodTracing("name_of_tracefile"); o This method usually goes in your onCreate() method of your starting activity, but really it can go in any method. Any name can be entered for the trace file name.  Debug.stopMethodTracing(); o This method usually goes in either of the methods of below for the Activity you are tracing. . onPause() . onStop() . onDestroy()  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> o You must add this permission to your android manifest file for your application in order to write the trace file to your SD Card on the emulator/device.</p><p>To pull the trace file off the SD card you must use DDMS in Eclipse/Motodev, select the file you wish to pull from the device/emulator and hit the pull icon in the top corner of the file explorer. Once the trace file is on your system simply drag the trace file on top of your traceview.bat in your SDK tools folder.</p><p>A general tip for identifying methods with performance issues is to identify where there is a large dip or large change in percentages in either the inclusive % or exclusive % column. Otherwise try to identify methods which are taking too long to execute when they should be executing much faster.</p><p>Useful links: http://developer.android.com/guide/developing/tools/traceview.html http://newfoo.net/2009/04/18/performance-tuning-android-applications.html http://stackoverflow.com/questions/1957135/how-to-test-the-performance-of-an-android- application</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us