Overview of Flex Profiler
-
Upload
prakash-raghavendra -
Category
Technology
-
view
5.274 -
download
4
Transcript of Overview of Flex Profiler
2007 Adobe Systems Incorporated. All Rights Reserved. 1
An Overview of Flex3 Profiler
2007 Adobe Systems Incorporated. All Rights Reserved.
Introduction
Improving performance of any application comes with experience and with extensive use of appropriate (profiler and other) tools
Needs knowledge of the application (Flex), the platform (Flash),programming guidelines (AS programming best practices) and the environment (OS, network, runtime)
Some of the typical tricks are using better algorithms, pre-compute and effective usage, effective GC, use strengths of the platform etc.
In this session, we will look at the profiler (the tool) for profiling a Flex application and NOT a tutorial on how to improve performance (may need separate session for this)
2007 Adobe Systems Incorporated. All Rights Reserved.
Flex3 Profiler
Flex Profiler gives you both performance profiles and memory profiles of an application. Using these, the developer can improve the performance and/or memory footprints of the application
Some of the important measurements that the Flex Profiler can give you about your application are:
Call Frequencies (P)
Method Duration (P)
Call Stacks (P)
Number of object instances and their sizes at any given time (M)
Garbage Collection and Loitering Objects (M)
Note that Profiler gives you lots of info about the application, however, it does not suggest/hint at things that you could do to improve theperformance or memory footprint. You need to do this by experience or by using general guidelines. More often than not, its trial-and-error.
2007 Adobe Systems Incorporated. All Rights Reserved.
Flex3 Profiler – How does it work?
Profiler is actually an agent running on the Flash player along with the application. You could chose to use your own agent, but Flex comes up with one such agent.
The agent periodically samples the Flash runtime and sends the data to the client (Flex Builder). Sampling frequency should be optimal not to loose critical samples and also to avoid redundancies.
The agent uses the sampler APIs of Flash platform (flash.sampler.*) to collect the profile of the application
The agent also samples some of the internal player actions like [mark], [sweep], [render] etc, which also could give good information about where the time is being spent. These actions are inserted into the stack to let user know what the Flash player is doing when the AS3 code is not being executed.
2007 Adobe Systems Incorporated. All Rights Reserved.
Using the Flex3 Profiler
Flex3 supports taking two types of profiles: Memory Profiles andPerformance Profiles
Memory profile gives an idea of how memory (mostly heap) is being used by the application while performance profiles gives an idea of where the time is being spent by the application.
Memory profile gives details like Live Memory Objects, Loitering Objects (between two snapshots), Allocation Tree, Object References
Performance profile gives details like Method statistics, Call graphs, Hot-spot stack traces etc
Typical cycle would be to take a profile, analyze, modify the application and do the profiling again (till you are satisfied with the performance). There is no limit to improving the performance.
2007 Adobe Systems Incorporated. All Rights Reserved.
Getting Started…
To start the profiling, press
2007 Adobe Systems Incorporated. All Rights Reserved.
Configuring the profiler
After launching, the application would stall the application till we start profiling
To start the profiling we need to configure the profiler (memory or performance etc) – see next slide
2007 Adobe Systems Incorporated. All Rights Reserved.
Wizard to configure the profiler
2007 Adobe Systems Incorporated. All Rights Reserved.
Profiler Panel
• Resume the application • Suspend the application• Terminate Profiling• Forced GC• Take a memory snapshot• Find potential Memory Leaks (needs two snapshot)• Allocation Tree• Reset• Take Performance Snapshot
2007 Adobe Systems Incorporated. All Rights Reserved.
Live Objects Panel
• Live object panel shows the class name and package name of each object which are currently in the heap• Shows the cumulative instances, currently live instances, etc
2007 Adobe Systems Incorporated. All Rights Reserved.
Live Objects Panel – Filtering the packages
2007 Adobe Systems Incorporated. All Rights Reserved.
Memory Snapshot Panel
2007 Adobe Systems Incorporated. All Rights Reserved.
Loitering Objects Panel
2007 Adobe Systems Incorporated. All Rights Reserved.
Loitering Objects, Object References and Allocation Tree Panels
The objects in loitering objects represent potential memory leaks. These are the objects which were created between two memory snapshots. Some could be expected and but some could be potential leaks.
By double-clicking a row in loitering objects panel, we get the “Object References Panel”. This panel gives details of references from one object to another which is keeping these “live” (that is being GC’ed)
Allocation Tree Panel would be useful in determining which functions use memory most. These functions are the ones which you may want to focus if you want to reduce the amount of memory that the application is taking
2007 Adobe Systems Incorporated. All Rights Reserved.
Object References and Allocation Tree Panel
2007 Adobe Systems Incorporated. All Rights Reserved.
Performance Profiling Panel
We could also get performance profile or a snapshot of performance at any instance using this feature
The Performance Profile panel gives a flat profile of all methods, with details like #calls made, cumulative times that the method has taken, average time for any call and the package that this method belongs to etc
When we double click any method, we would get the “method statistics”which gives the traces of the calls of this method (including callers and callees of this method) with their times. This gives details like which call trace of this method was taking most time
We could drill down to any levels similarly of callers/callees
2007 Adobe Systems Incorporated. All Rights Reserved.
Performance Profiling
2007 Adobe Systems Incorporated. All Rights Reserved.
Method Statistics Panel
2007 Adobe Systems Incorporated. All Rights Reserved.
Launching external application in a swf
2007 Adobe Systems Incorporated. All Rights Reserved.
Player and Browser selection
2007 Adobe Systems Incorporated. All Rights Reserved.
General Guideline for Improving the deployment
Reducing SWF files by increasing optimization levels, disabling debugging, using “strict” mode (dummy imports), examine linker dependencies, avoiding initializing unused classes, using multiple SWF files, dynamic loading of SWFs (using loaders) etc. (Memory)
Using ordered creation of objects, using deferred creation, destroying unused objects, by removing event listeners (GCed) (Performance)
Loading style sheets at runtime using StyleManager, working withcontainers effectively, minimizing container nesting, techniques to use rendering speed (using list controls than repeaters etc)
Use Weakreferences wherever applicable – like in EventListeners and Dictionary (hash table data structure) – Esp with dynamic content and loaded content (with Flash9) also with untrusted contents (SWFs)
More at http://livedocs.adobe.com/labs/flex3/html/help.html
2007 Adobe Systems Incorporated. All Rights Reserved. 19