blog
Flex Size Report at Jozef Chúťka's blog
January 5, 2010
compiler flag link report xml xsl xslt
Flex Size Report
linkreport
This post is for everyone who is looking for clear and readeable size report from flex.
1. Define “-link-report” flag for compiler 2. Export / publish your project 3. Create static .xsl file 4. Link .xsl file into generated .xml size report
1. Define “-link-report” flag for compiler
In order to get raw .xml size report from flex project you have to define “-link-report” flag. In flex project go to “File / Properties / Flex Compiler / Additional compiler arguments” text field and append neccesary “-link-report” flag. Your argument query now should look someting like this
-locale en_US -link-report=report.xml -optimize2. Export / publish your project
Now you can release export or debug export your project to get your report. report.xml should appear in bin-debug directory.
3. Create static .xsl file
In same directory, create empty file named “flexSizeReport.xsl”. Put following content into this file and save:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<html>
<body>
<h1>ActionScript Link Report</h1>
<h2>Custom Classes</h2>
<table border="1">
<tr>
<th align="left">Name</th>
<th align="left">Size (B)</th>
<th align="left">Optimized Size (B)</th>
</tr>
<xsl:for-each select="report/scripts/script">
<xsl:sort select="@optimizedsize" data-type="number" order="descending"/>
<xsl:if test="not(contains(@name, 'frameworks'))">
<tr>
<td><xsl:value-of select="@name"/></td>
<td align="right"><xsl:value-of select="@size"/></td>
<td align="right"><xsl:value-of select="@optimizedsize"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
<h2>Framework Classes</h2>
<table border="1">
<tr>
<th align="left">Name</th>
<th align="left">Size (B)</th>
<th align="left">Optimized Size (B)</th>
</tr>
<xsl:for-each select="report/scripts/script">
<xsl:sort select="@optimizedsize" data-type="number" order="descending"/>
<xsl:if test="contains(@name, 'frameworks')">
<tr>
<td><xsl:value-of select="@name"/></td>
<td align="right"><xsl:value-of select="@size"/></td>
<td align="right"><xsl:value-of select="@optimizedsize"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>Now open report.xml file. It should contain some content like:
<report>
<scripts>
<script name="Drive:\Path\MyProject\src\accessibility\ComboBoxItemAccessibility.as" mod="1217893038671" size="1593" optimizedsize="875">
<def id="accessibility:ComboBoxItemAccessibility" />
<pre id="accessibility:ButtonAccessibility" />
<dep id="flash.events:MouseEvent" />
<dep id="accessibility:Constants" />
<dep id="MenuItem" />
<dep id="AS3" />
</script>
</scripts>
</report>4. Link .xsl file into generated .xml size report
Prepend this content with two lines:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="flexSizeReport.xsl"?>
<report>
<scripts>...Save report.xml and open it in some modern browser, that can handle xslt (Chrome or Firefox work just fine). Now you see your .xml report parsed by .xsl file into two separated tables (custom classes, framework classes) ordered by optimized size descending.
Read more about “-link-report” flag here:
Using the FlexBuilder “-link-report” compiler option to generate
Visualizing mxmlc’s link report
You may Leave a comment or Subscribe to Comments RSS or Trackback this entry.
1 comment so far
[Flex]모듈사이즈 줄이기 January 14, 2010 07:40 […] 다음은 xsl을 이용하여 report.xml을 이쁘게 보는 방법을 설명한 글 http://blog.yoz.sk/2010/01/flex-size-report/ […]
Leave a comment
Please be polite and on topic. Your e-mail will never be published.