<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Miscellaneous Utility Functions</title>
	<atom:link href="http://jacksondunstan.com/articles/525/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/525</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:30:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: theme park tours</title>
		<link>http://jacksondunstan.com/articles/525/comment-page-1#comment-750</link>
		<dc:creator>theme park tours</dc:creator>
		<pubDate>Wed, 28 Jul 2010 03:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=525#comment-750</guid>
		<description>Been looking for some good comment suggestions for a while now. This is perfect!</description>
		<content:encoded><![CDATA[<p>Been looking for some good comment suggestions for a while now. This is perfect!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/525/comment-page-1#comment-470</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 30 Dec 2009 18:36:59 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=525#comment-470</guid>
		<description>Cool, this is more incentive to change my version. Here&#039;s my performance test:

&lt;pre lang=&quot;actionscript3&quot;&gt;
const ITERATIONS:int = 1000000;
var i:int;
var beforeTime:int;

beforeTime = getTimer();
for (i = 0; i &lt; ITERATIONS; ++i)
{
	throwForStackTrace();
}
log(&quot;throw: &quot; + (getTimer()-beforeTime));

beforeTime = getTimer();
for (i = 0; i &lt; ITERATIONS; ++i)
{
	newForStackTrace();
}
log(&quot;new: &quot; + (getTimer()-beforeTime));
&lt;/pre&gt;

With results:

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Environment&lt;/th&gt;&lt;th&gt;Throw&lt;/th&gt;&lt;th&gt;New&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3.0 Ghz Intel Core 2 Duo, 4 GB, Windows XP&lt;/td&gt;&lt;td&gt;1298&lt;/td&gt;&lt;td&gt;403&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

So it&#039;s about 3x faster. Thanks for the tips and tests grgrdvrt and NoriSte!</description>
		<content:encoded><![CDATA[<p>Cool, this is more incentive to change my version. Here&#8217;s my performance test:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">const</span> ITERATIONS<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1000000</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> beforeTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> ITERATIONS; <span style="color: #000000; font-weight: bold;">++</span>i<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    throwForStackTrace<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;throw: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span>beforeTime<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> ITERATIONS; <span style="color: #000000; font-weight: bold;">++</span>i<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    newForStackTrace<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;new: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span>beforeTime<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>With results:</p>
<table>
<tr>
<th>Environment</th>
<th>Throw</th>
<th>New</th>
</tr>
<tr>
<td>3.0 Ghz Intel Core 2 Duo, 4 GB, Windows XP</td>
<td>1298</td>
<td>403</td>
</tr>
</table>
<p>So it&#8217;s about 3x faster. Thanks for the tips and tests grgrdvrt and NoriSte!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NoriSte</title>
		<link>http://jacksondunstan.com/articles/525/comment-page-1#comment-468</link>
		<dc:creator>NoriSte</dc:creator>
		<pubDate>Wed, 30 Dec 2009 16:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=525#comment-468</guid>
		<description>and not throwing an error is faster, here the code

&lt;pre lang=&quot;actionscript3&quot;&gt;
		public function throwForStackTrace () : String
		{
			try
			{
				throw( new Error() );
			}
			catch( error : Error )
			{
				return error.getStackTrace();;
			}
			
			return null;
		}
		
		
		
		public function newForStackTrace () : String
		{
			return new Error().getStackTrace();
		}
&lt;/pre&gt;

and the result:

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
throwForStackTrace (100000 iterations)                                  
Player version: MAC 10,0,22,91 (debug)
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
throwForStackTrace                                         2710     0.03
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
newForStackTrace (100000 iterations)                                    
Player version: MAC 10,0,22,91 (debug)
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
newForStackTrace                                           1774     0.02
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</description>
		<content:encoded><![CDATA[<p>and not throwing an error is faster, here the code</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> throwForStackTrace <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">try</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">error</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Error</span> <span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">error</span>.<span style="color: #004993;">getStackTrace</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> newForStackTrace <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">getStackTrace</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>and the result:</p>
<p>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
throwForStackTrace (100000 iterations)<br />
Player version: MAC 10,0,22,91 (debug)<br />
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;ttl ms&#8230;avg ms<br />
throwForStackTrace                                         2710     0.03<br />
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</p>
<p>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
newForStackTrace (100000 iterations)<br />
Player version: MAC 10,0,22,91 (debug)<br />
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;ttl ms&#8230;avg ms<br />
newForStackTrace                                           1774     0.02<br />
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grgrdvrt</title>
		<link>http://jacksondunstan.com/articles/525/comment-page-1#comment-444</link>
		<dc:creator>grgrdvrt</dc:creator>
		<pubDate>Sat, 12 Dec 2009 12:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=525#comment-444</guid>
		<description>The getTraceStack is very nice, thank you!

However it seems to be possible to get the stack trace without throwing the error:

&lt;pre lang=&quot;actionscript3&quot;&gt;trace(new Error().getStackTrace());&lt;pre&gt;

I know I will use it a lot, thank you again!</description>
		<content:encoded><![CDATA[<p>The getTraceStack is very nice, thank you!</p>
<p>However it seems to be possible to get the stack trace without throwing the error:</p>
<pre lang="actionscript3">trace(new Error().getStackTrace());</pre>
<pre>

I know I will use it a lot, thank you again!</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
