Profiling CPU in Flash and Flex Applications in IntelliJ IDEA
January 11th, 2012 by fedor.korotkovHello guys! Just recently we’ve published an update to our Flash/Flex Profiler plugin that gives you a powerful and easy to use toolset for profiling of Flash-based applications in IntelliJ IDEA.
Let us give you a brief overview of what you can do with it.
Sure, the first thing to start with is installation. Nothing complex here—go to File menu, open Settings, then click Plugins and Browse repositories (if you’re on Mac OS, the path is slightly different—you should look in IntelliJ IDEA, then Preferences, Plugins, and then Browse repositories). After you’re there, find ActionScript Profiler and install it.

Let’s play with this extremely simple Flex component to set an example.

As you can see, it’s a rather heavy computation implemented in Task.calculateResult() method that is invoked 1000 times in a cycle from clickHandler() function that handles the mouse click.
To start the profiling we open context menu for the main class and click Profile:

Once the application is built and started, an empty Profiling window opens. Let’s tell profiler to start collecting CPU usage data by clicking Start CPU Profiling.

Now switch to our application, click Calculate and wait for resulting popup to appear. Then, we need to go back to IDE and click Stop CPU Profiling to compute the results—and here they are!
Invoked functions table shows the list of called functions, with child nodes representing points from which parent node was called:

We can easily compare timings by sorting the table by self time or cumulative time (just click column header for that).
Note: Edit source action is available for every item either via context menu or with F4 keyboard shortcut, so you can go to source code directly from profiling results.
Merged callees table at the bottom shows all the functions that were called (directly or indirectly) from the function selected in the upper table. You can sort this table as well to compare every detail and expand items to drill down through the call chains.

This concludes today’s post about CPU profiling. We hope you enjoyed it. In the next posts we are going to take a look at memory profiling capabilities and memory leaks hunting techniques. Please report any problems to the bug tracker. Stay tuned!
Plugin is compatible with IntelliJ IDEA 11.0 and 10.5. It was tested with 32-bit Flash Player 9, 10 and 11 on Windows (32- and 64-bit), Mac OS (32-bit and 64-bit) and Linux (32-bit).
Profile with pleasure!
Tags: actionscript, Flash, Flex, Nika, performance, profiler, Xena

January 11th, 2012 at 7:14 am
This is a much welcomed and awesome addition to IDEA, thanks @jetbrains!
January 17th, 2012 at 1:02 pm
I only see “Waiting for profiling agent to connect…” — what am I doing wrong?
January 18th, 2012 at 2:08 am
It seems the problem is in mm.cfg file. Did you override home directory? Do you use debug player?
January 26th, 2012 at 9:30 am
looks very nice, but i got the same problem as already mentioned: “Waiting for profiling agent to connect …”
I use DebugPlayer!
Is there a special configuration in mm.cfg necessary?
I just use the following three props.
ErrorReportingEnable=1
TraceOutputFileEnable=1
TraceOutputFileName=C:\Users\s …
February 1st, 2012 at 3:47 am
Hey guys!
I see Sampling started in profile window, yet I don’t see any Calculate button. Where should it be?
Also I don’t have admin rights on PC.
What should I do to make it works properly?
Thanks.
February 1st, 2012 at 6:39 am
Hi Danil!
Calculate button is part of example code(look at second screenshot).
February 1st, 2012 at 6:56 am
basti, it’s very strange. There must be at least one more property:
PreloadSwf=C:\…
When you start profiling application this property appears in mm.cfg. It disappears when you close the window.
February 1st, 2012 at 6:24 pm
I am still being unable to connect to the profiler with message “Waiting for profiling agent to connect…”
Please, how to resolve this on a mac? What is mm.cfg?
February 20th, 2012 at 4:18 pm
I’m getting an HTTP Error 500 when trying to browse the plugins or download ActionScript Profiler. I’m on a Mac OS 10.6.4.
Too bad, can’t wait to test it !