views:

546

answers:

2

I just got Flex Builder Professional for the profiling support, and although I can make the profiler work, I am having trouble isolating samples to just a section of my code. Trying to click "clear profiling data" and "stop collecting" in the UI just isn't cutting it.

I'd like to be able to, in my code, do something like:

startProfiling(); // do stuff stopProfiling();

and have that "snapshot" of profiling data visible in the UI.

I can't find any information on this online at all. I know about flash.sampler.* but I don't know how to make flex builder and flash.sampler talk to each other.

This is a pretty routine way to trigger profiler data collection, and I am very frustrated trying to find a solution and hoping someone else has already figured it out.

A: 

I don't believe this is possible. The profile in flex is like the debugger. You have to hook up to a specific instance of it and profile the application from start to finish. Here is a link that talks more about the Flex 3 profiler and might give you some more information on a different way to achieve what you are looking for.

http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Performance_and_Memory_Profiling

Ryan Guill
This is actually factually false. You don't have to profile the entire run from start to finish. In the Flex Builder GUI you can stop/start/clear performance sample data and just test sections of code. I just want to do it programmatically.
apinstein
It is actually factually accurate. While you can clear all information you have gathered up to a point, or not start gathering information until a certain point, you have to do this from the GUI and you can only do this if you have launched a profile session. You cannot do it with code.
Ryan Guill
You said "profile the application from start to finish" which is not true. You can profile periods of time during a running app that are not "start to finish." That is what I downmodded.
apinstein
Your 2nd comment is more correct, but still wrong. You can use flash.sampler to start/stop collection. I just want to be able to use the flash.sampler API's to change what stats are shown in the GUI. This is a standard feature of every profiler I've ever used, and I need to do it for Flex Builder.
apinstein
Well it sounds like you need to reword your question giving all the available information. Regardless, the question sounds like you want it to conditionally start profiling in certain cases. My answer in response to that is that you must have a connection to the profile to get profile information.
Ryan Guill
Either way, good luck getting an answer.
Ryan Guill
Ryan, you can conditionally start/stop profiling programatically with the flash.sampler APIs, but it sounds like he wants to filter the results (or something, you're right in that the question isn't all that clear)
Joel Hooks
+1  A: 

So you checked out the flash.sampler APIs? When you hook up the profiler it is probably calling startSampling automatically. Have you tried calling pauseSampling from your app and then calling startSampling when you want just your stuff collected?

I've tried using flash.sampler.startSampling and stopSampling and it seems to have no effect on the output.After reading a little more today it seems that the Flash profiler is actually based on sampling rather than recording of all calls. I wonder if that has any effect on this situation.
apinstein
Of course I used flash.sampler.clearSamples() as well with this and no luck.
apinstein