<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1-alpha-2475" -->
<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"
		>
	<channel>
		<title>Post Topic &#187; Tag: Duff&#039;s Device - Recent Posts</title>
		<link>http://posttopic.com/tags/duff039s-device</link>
		<description>Open For Discussion</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Sep 2010 16:27:32 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1-alpha-2475</generator>
				<atom:link href="http://posttopic.com/rss/tags/duff039s-device" rel="self" type="application/rss+xml" />

		<item>
			<title>Chad Smith on "jQuery Duff&#039;s Device"</title>
			<link>http://posttopic.com/topic/jquery-duffs-device#post-146</link>
			<pubDate>Fri, 28 Aug 2009 05:28:01 +0000</pubDate>
			<dc:creator>Chad Smith</dc:creator>
			<guid isPermaLink="false">146@http://posttopic.com/</guid>
			<description><![CDATA[<h3>Duff's device explained</h3>
<br />
Duff's device makes loops faster by using a method called unrolling. When you have a typical loop, the time it takes to execute that loop equals the time to execute function each time plus the time to see if it should continue each time. So the formula for a standard loop would be:<br />
<br />
Number of iterations (N)<br />
Time to execute (E)<br />
Time to check to continue (C)<br />
<br />
<code>T=NE+NC</code><br />
<br />
Duff says if we iterate our loop and only do test every 8 times (plus a few remainders) it would go faster, and it does. Duff's device "unrolls" the loop, or essentially executes more and checks less to see if it should continue.  The function it uses is along the lines of:<br />
<br />
Number of iterations (N)<br />
Time to execute (E)<br />
Time to check to continue (C)<br />
<br />
<code>T=NE+C(N%8+floor(N/8))</code>(plus trivial operation time for Floor, % and / one time)<br />
<br />
This means Duff's device is faster than a standard loop when<br />
<br />
<code><a href="http://www.wolframalpha.com/input/?i=N+mod+8%2Bfloor%28N%2F8%29%3CN">N%8+floor(N/8)&#60;N</a></code>]]></description>
					</item>
		<item>
			<title>Chad Smith on "jQuery Duff&#039;s Device"</title>
			<link>http://posttopic.com/topic/jquery-duffs-device#post-145</link>
			<pubDate>Fri, 28 Aug 2009 05:54:50 +0000</pubDate>
			<dc:creator>Chad Smith</dc:creator>
			<guid isPermaLink="false">145@http://posttopic.com/</guid>
			<description><![CDATA[<style type="text/css">.code{color:#3a6ff8}.code span{color:#0ec925}h3 a{color:#333;cursor:pointer;text-decoration:none}.small{font-size:.8em}</style>
<h2><a href="http://mktgdept.com/jquery-duffs-device">jQuery Duff's Device</a></h2>
<h3>Summary</h3>
Use <a href="http://en.wikipedia.org/wiki/Duff%27s_device">Duff's device</a> for faster<sup>*</sup> loops.<br />
<br />
<h3>Author</h3>
<a href="http://twitter.com/chadsmith">Chad Smith</a> (<a href="&#109;&#97;&#x69;&#x6c;&#x74;&#111;&#58;&#x63;&#104;&#97;&#100;&#x40;&#x6e;&#111;&#x73;&#x70;&#x61;&#x6d;&#46;&#x6d;&#101;">email</a>)<br />
<br />
<h3>Requires</h3>
<ul>
<li><a href="http://code.jquery.com/jquery-latest.js">jQuery</a></li>
</ul>
<h3>Download</h3>
<a href="http://mktgdept.com/js/jquery-duff.js?v0.0.2">jquery-duff.js</a> (842 bytes)<br />
<br />
<h3>License</h3>
Dual licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a> and <a href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses.<br />
<br />
<h3>Usage</h3>
Use: <span class="code">$(element).<span>duff</span>(function(){...});</span> or <span class="code">$.<span>duff</span>(element,function(){...});</span><br />
In place of: <span class="code">$(element).<span>each</span>(function(){...});</span> and <span class="code">$.<span>each</span>(element,function(){...});</span><br />
<br />
<span class="small"><sup>*</sup>Duff's device is faster in many cases, but not every case. Loop speed depends on the browser and number of iterations, and can differ on each run.</span><br />
<br />
<h3>Version History</h3>
<ul>
<li><strong><a href="http://plugins.jquery.com/node/10014">v0.0.2</a></strong> - August 28th, 2009</li>
<li><strong><a href="http://plugins.jquery.com/node/9991">v0.0.1</a></strong> - August 27th, 2009</li>
</ul>
<h3><a href="http://posttopic.com/topic/jquery-duffs-device">Support</a></h3>
<h3><a href="http://mktgdept.com/jquery-duffs-device">Examples</a></h3>]]></description>
					</item>

	</channel>
</rss>
