3

I'm currently work on a tool that allow us to view wich function are time consuming in a big as3/Air project (more than 2000 class) to identify bottleneck and functions that need optimisations.

One way to achieve this is to use Flash Builder Profiler but it's very very slow and it crashs after 1 or 2 minutes. The other way is to manualy write a file with most important function time consuming informations. But it's a manual process and I can't cover all project's functions.

So I'm looking for a way to inject as3 bytecode directly in the compiled swf. With such tool, I will inject a log after each function call and so I will be able to cover all project's function.

Some as3 libs exists to do such thing (AS3Commons ByteCode) but doesn't works fine with my project (I get parsing error) and as3 is slow.

Simon Eyraud
  • 2,445
  • 1
  • 20
  • 22

2 Answers2

9

I see four options :

  • First, I'm thinking of Apparat, by Joa Ebert (thanks, dude), which provides tools for ABC bytecode optimization, as well as a very deep API for the manipulation of this bytecode. It is written in Scala, so it's also a good moment to learn about this awesome language.

  • Also, you could write your own tool. The ABC (ActionScript Bytecode) format is well documented, as well as its container, the SWF file format. It might be not too hard to parse both files for interesting tags and add needed instructions in the bytecode.

  • On a more "simple" approach, the SWF and ABC compiler most of us are using, mxmlc, is open-source. You could try to edit the compiler code directly to do what you want. Everything you need for that is in the Adobe OpenSource Flex SDK web site.

  • And as an alternative answer to your question, instead of trying to inject bytecode in the SWF (which will always have an impact on the performances of the global application), you could use the awesome AS3Trace/AS3DynamicProfile options on mm.cfg, to have a full log of execution of each function, as well as profiling informations about the opcodes execution. More on that here.

To conclude, such external profiling tool will be an awesome application to be open-sourced and released to the community, since more and more "big" AS3 projects are coming out these days. ;)

Tyn
  • 2,184
  • 1
  • 13
  • 20
3

Finaly, I used a python script to add As3 to each action script files. My work can be found here : http://code.google.com/p/as3-performances-analyzer/

Simon Eyraud
  • 2,445
  • 1
  • 20
  • 22