« AIR support added to Antennae build template system | Main | Flex Cookbook Code License? »

Styles, Fonts, and Compile Time

There has been some recent conversation about the impact of styles and fonts on compilation time in Flex Builder 3. I figured I'd take the project I'm currently working on and see what the numbers came out as.

Some more details about the test: About 700KB of raw .as and .mxml code. 2 separate CSS files are imported. 120KB of TTF fonts. 650KB of SWF fonts. Compiling using Flex 2.0.1 Hotfix 3 SDK. Each tests was run 3 times with the average time reported. Each test was run by changing text in the top level MXML component, saving it, and timing a manual build. Timing was from time of click until the progress view reported the build was finished. Copy non-embedded and generate HTML template were disabled.

As with all measurements these should be taken with a grain of salt and are meant to be representative. Your project will vary, yadda, yadda, yadda.

Compile State Compile Time (in seconds)
All styles, 11 SWF fonts, and 2 TTF fonts 11.3
No styles or fonts 4.8
All styles and no fonts 6.9
All styles and 8 SWF fonts 9.1
All styles and 2 TTF fonts 9.1
All styles and 3 SWF fonts 8.1

Clearly using TTF encoded fonts has a higher overhead than SWF encoded fonts. More fonts take more time. The next item to explore is using Flex Builder 3's compile CSS to SWF option. Doing that would require looking at application startup time since the styles would no longer be compiled in but instead loaded during startup.

Tags: as3 css flex

Comments

TTF fonts are slow because there's a lot of legwork to convert the glyphs to the SWF format. To see yet another difference in performance, try setting "flashType" to false in the CSS/Embed of the font. This turns off one part of the conversation, and you should see a speedup. You should also see a speedup after the first time the font is compiled- that is, when you recompile the MXML page, that second compilation with the same TTF font should be faster. If not, that's a bug (based on my old knowledge of the Flex compiler at least).