Sometimes you need to test your Flash stuff with different plugin versions. Even if you just want to run some performance tests, it is very useful to switch to the release player (see below for another example).

For windows there is a neat Firefox Plugin that makes switching quite a snap. On Mac there is one too – I haven’t tested it, but it’s supposed to work (though I’m not too sure about that when I read these comments here). Still I prefer to work with Safari and I kind of dislike the thought of starting Firefox to just switch Plugins.

wspluginswitcher-iconFortunately I’ve found another solution: WSPluginSwitcher. This one comes as a Cocoa app and once configured (you really should read this wiki page), it works real well for me. Also they have prepared plugin versions for you to download (though the most recents are missing, but no big deal really).

As for the speed tests, let me just give you another example (impressing enough for me to wanna switch players for real world testing).

In Debug Player:

method...................................................ttl ms...avg ms
tare [2]                                                      0     0.00
CSSFastParser                                               603   120.60
CSSRegExpParserFast                                         987   197.40
CSSRegExpParserFastAdvanced                                1457   291.40
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

In Release Player:

method...................................................ttl ms...avg ms
tare [2]                                                      0     0.00
CSSFastParser                                               354    70.80
CSSRegExpParserFast                                         972   194.40
CSSRegExpParserFastAdvanced                                1469   293.80
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Both 10.0.22.87, and exported as release swf. Oh, and by the way tested with another useful tool from Grant Skinner: AS3 Performance Testing Harness.

I did some speed tests today, comparing two string parsing methods. And I’ve made some very interesting discoveries: The execution speed between SWF compiled for debugging and those compiled without differs.

Ha! Okay, that’s not that much of news (even for me). But what astonishes me is how much this speed gap can be, especially when it comes to massive data calculations. I somehow always had a somewhat 20 percent speed decrease in mind (I was just presuming, me dumb). But for a 3d particle test we’re talking factor 8!!

Now this made me curious… so I’ve tested with Debug and Release Player both debug and release SWFs:

Debug Player running Debug SWF

Flash Debug in Debug

Debug Player running Release SWF

Release in Debug

Release Player running Debug SWF

Debug in Release

Release Player running Release SWF

Release in Release

A few conclusions:

  • Never release a SWF file with debug code (or otherwise said: put only stuff online from bin-release, never bin-debug). Though common users won’t notice the speed decrease, your friendly flash developers may, at least if you’re app is somewhat cpu intensive. And of course: debug SWF are much bigger in size (just in case you give a fuck about flash devs ;-)
  • Speed tests should be played in the release player. Why? After all, I wouldn’t care if the relation would stay the same. Usually you just need to know how much faster one thing is compared to the other one, so that would do it. But unfortunately the ratio won’t always be the same. In the above example the ration is 3.66 for debug and 2.92 for release. And it can differ muuuuch more.

The last one bugs me quite a bit. It’s just a pain in the ass to export a release build each time you wanna compare performance. And it also means you can’t do quick’n'dirty trace outputs for the time result (not a biggy if you’re testing within a Flex project though).

So here we go with two wishes for Adobe:

  • Let us quickly test release builds within Flex Builder (a simple command would do it – I thought it might be «Run Testapp» (instead of «Debug Testapp»), but that just doesn’t bring up the Debugger (and same speed)
  • An option to turn off debugging mode in Debug Player!!! That would solve almost all problems, and we could also use our Plugin for normal browsing without performance penalties (is this why Youtube eats so much cpu here?

Most of the Flash application deal with server side data like images, xml files etc. We tend to forget about that because the default Run or Debug commands in Flex will open a local html file (and also because we developers often have quite a nice internet connection when testing remotely). Thus all data is loaded nearly instantely.

In Flash we have a menu command called «Simulate Download» to see how things run at different bandwidth situations. But how to achieve this in Flex?

I’ve been using Sloppy for a long time. It’s little java app that can be started via a simple web click. It’s really easy to use and does very well what it does. For debugging your app (your flash website) throttled in Flex Builder simply follow these steps:

 

  1. Open the Sloppy website
  2. Click the little Sloppy icon:

  3. A «sloppy.jnlp» file is downloaded. Open it if doesn’t open automatically.
  4. The actual application will be downloaded and started. If it asks you to trust: trust! :-)
  5. Enter the address of your html file in the bin-debug or bin-release folder. It should be a webserver address. I usually create a symbolic link of my project directory and put it into my local webserver directory.
  6. Click «Go» – this will start the Sloppy proxy and open the page in your default browser. 
  7. Copy the address from the browser window (usually http://127.0.0.1:7569/your/path)
  8. You may close the window. Go to Flex Builder and open the project properties (right click on project folder, last item). In an Actionscript Project, switch to ActionScript Build Path.
     
  9. Enter the copied address into «Output folder URL», clear the html name (e.g. App.html).
  10. Click «OK» and you’re done. You can now Run and Debug as if your website was hosted on some server and you had a 256K ADSL connection (instead of your T1).

Note: I tried to automate the whole thing (with Ant of course) and succeeded to a certain limit. What I did was download Sloopy’s source code (java), modify it so it can handle more terminal attributes and build the  .jar file. This can be run on command line, which will start the sloopy server. So I created an ant file that does all that for me, but this ant file would only be cool, if it could also trigger the run or debug commands and modify the output folder url. I haven’t found a way (at least not a satisfying one) to do this, so I might just follow the manual street for once ;)

Another note: If you are windows user, you might wanna try this Firefox plugin: Firefox Throttle