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 -optimize

2. 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:

1 comment so far

  1. […] 다음은 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.