If you haven’t read my previous blog about the Flex Profiler, I recommend you go take a look…
Ever since the Flex Profiler was made available in early FB3 beta, I’ve been hearing some legitimate concerns. One example and I paraphrase:
It’s great that Flex has implemented a large number of Eclipse views for the main use cases. But they are not showing me what I want…
Another example:
The steps of showing profiling data are quite simple and easy to remember. But once the data is shown, it seems to me that it usually takes too many steps to navigate to the root cause of the performance/memory problems. Why can’t the tool be smarter?
Like I said, these are legitimate concerns and I’m sure the Flex engineering team is going to improve the profiler going forward. How? I’m going to give my $0.02 here..
Just to recap, there are 4 pieces in the profiler architecture:
- The flash.sampler.* API support and the PreloadSwf support in the Player
- ProfilerAgent.swf as the PreloadSwf
- Java-based profiler client library
- Eclipse plugin + the graphical user interface
As you can see, if the current Flex profiler doesn’t work for you and you can’t wait for any improvements in the next release, your most logical option will be the flash.sampler API, i.e. write your own profiler agent or simply use the flash.sampler classes in your application. There are many advantages and disadvantages.
Advantages:
- Free. You don’t have to pay several hundred dollars more for FB Pro. Well, your time is money too. so, this point doesn’t make sense.
- Your profiler agent could be very lightweight if you know exactly what you’re looking for.
Disadvantages:
- You want a profiler agent that is lightweight, i.e. not using up too much of CPU cycles and Player memory. However, it could take you a long time to write a good one.
- You have to use another timing approach to verify the correctness of your implementation.
- You may waste your valuable time if you have to move your sampling code from one wrong spot to another in your application.
I think most developers would avoid writing their own. At some point, some developers/software vendors may make theirs available (free of charge? who knows?). I don’t see that in my crystal ball yet.
If the current Flex profiler works for you but you want some enhancements, feel free to submit your enhancement requests. However, they may not work on every enhancement (e.g. they may not build 15 more new profiler views). Instead, you should tell Adobe the following:
- Expose the API of the Java-based profiler client library. The API returns pre-calculated data that’s ready for tabulation. It can also return raw data from ProfilerAgent.swf if you want to do your own calculations.
- Expose the API of the foundation classes (e.g. the base class of the performance/memory views) and the utility classes.
- Define extension points in the Eclipse-based profiler plugin.
If Adobe listens to you and do the above, it will be very easy for you to extend the Flex profiler. I think it’s in their best interest to provide the flexibility you need because the Player doesn’t provide profiling support in a closed environment – the flash.sampler API is available to everyone. Sooner or later, the Flex Profiler will not be the only game in town.
Another great thing that developers can do if the API of the profiler client library is exposed is static code analysis. Did you notice that in the inclusion/exclusion filter dialog, it automatically shows a list of packages as you type?
The package list is built dynamically by the Flex Profiler by decoding the bytecodes in your application. Yep, the application SWF is available via the profiler client library API. That’s why I think someone could write a profiler extension plugin that uses SWFKit (the open source SWF encoding/decoding library) to decode and run static code analysis. It sure would be very nice to be able to do both static/dynamic code analysis with the Flex Profiler.



