Pref Presentation (2)
-
Upload
prachi-patil -
Category
Documents
-
view
124 -
download
0
Transcript of Pref Presentation (2)
Code level fixes
DDMS tools&
Developer Options
GPU overdraw
Heap dumpAllocation Tracker
Hierarchy ViewerGPU Rendering
Trace Viewer
Optimized Imports
Performance tweaks
Lint Tool
Avoid memory leaks
ImproveCode
Analyse & improve app performance
Smooth, Optimized
app
Optimization
Avoid Memory leaks
❖ Use Drawables efficiently❖ Broadcast❖ Context related leaks
● Application level context● Activity level context
Performance Tweaks
❖ Use Static Final to declare Constants.❖ Access variables directly instead of getter/setter for internal
use.❖ Avoid Creating Unnecessary Objects.❖ Use loops efficiently.
For LoopCode Snippet
Log.i(TAG, "-------------------------------------------------");
Log.i(TAG, "-------Start: FOR loop one");
for (int j = 0; j < mCountList.size(); j++) {
//stuff
}
Log.i(TAG, "-------End: FOR loop one");
Log.i(TAG, "-------Start: FOR loop two");
int count = mCountList.size();
for (int j = 0; j < count; j++) {
//stuff
}
Log.i(TAG, "-------End: FOR loop two");
Log.i(TAG, "-------------------------------------------------");
Logcat
Lint Tool
❖ Static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization.
Lint Result To run Lint tool Analyze Inspect Code
DDMS & Developers Options
❖ GPU overdraw❖ GPU Rendering❖ Trace Viewer❖ Hierarchy Viewer❖ Heap dump❖ Allocation Tracker
GPU Overdraw
Atleast 4X
3X
2X
1X
Debug GPU overdraw:
Lets you see when and where this is happening so you know if it is a problem.
Buggy Without Overdraw Issue
Example of GPU overdraw
Profile GPU rendering❖ Blue bar represents the time used
to create and update the View's display lists.
❖ Red bar represents the time spent by Android's 2D renderer issuing commands to OpenGL to draw and redraw display lists.
❖ Orange bar represents the time CPU is waiting for the GPU to finish its work.
Hierarchy Viewer tool ❖ Allows you to debug and optimize your user interface. ❖ It provides a visual representation of the layout's View hierarchy
(the Layout View) and a magnified inspector of the display (the Pixel Perfect View).
Systrace tool
❖ It shows where time and CPU cycles are being spent, displaying what each thread and process is doing at any given time.
Heap Option
❖ To get a little information about what kind of memory your application is using and when, you can view real-time updates to your app's heap in the Device Monitor.
Allocation Tracker❖ Allocation Tracker records an app's memory allocations and
lists all allocated objects for the profiling cycle with their call stack, size, and allocating code.
❖ Identifying where many similar object types, from roughly the same call stack, are allocated and deallocated over a very short period of time.
❖ Finding the places in your code that may contribute to inefficient memory use.
Source
❖ http://developer.android.com/tools/help/index.html❖ http://android-developers.blogspot.in/