Pref Presentation (2)
-
Upload
prachi-patil -
Category
Documents
-
view
126 -
download
0
Transcript of Pref Presentation (2)
![Page 1: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/1.jpg)
![Page 2: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/2.jpg)
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
![Page 3: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/3.jpg)
Avoid Memory leaks
❖ Use Drawables efficiently❖ Broadcast❖ Context related leaks
● Application level context● Activity level context
![Page 4: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/4.jpg)
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.
![Page 5: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/5.jpg)
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, "-------------------------------------------------");
![Page 6: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/6.jpg)
Logcat
![Page 7: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/7.jpg)
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.
![Page 8: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/8.jpg)
Lint Result To run Lint tool Analyze Inspect Code
![Page 9: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/9.jpg)
DDMS & Developers Options
❖ GPU overdraw❖ GPU Rendering❖ Trace Viewer❖ Hierarchy Viewer❖ Heap dump❖ Allocation Tracker
![Page 10: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/10.jpg)
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.
![Page 11: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/11.jpg)
Buggy Without Overdraw Issue
Example of GPU overdraw
![Page 12: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/12.jpg)
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.
![Page 13: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/13.jpg)
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).
![Page 14: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/14.jpg)
Systrace tool
❖ It shows where time and CPU cycles are being spent, displaying what each thread and process is doing at any given time.
![Page 15: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/15.jpg)
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.
![Page 16: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/16.jpg)
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.
![Page 17: Pref Presentation (2)](https://reader031.fdocuments.co/reader031/viewer/2022013120/58ef1b1e1a28abe12e8b4609/html5/thumbnails/17.jpg)
Source
❖ http://developer.android.com/tools/help/index.html❖ http://android-developers.blogspot.in/