<div dir="ltr">FWIW:<div><br></div><div><div>Performance differences in loops exist in any language. And the vast majority of cases it is only a matter of compiler optimization difference:</div><div><br></div><div>Using this example:</div><div><br></div><div><a href="http://stackoverflow.com/a/2959105">http://stackoverflow.com/a/2959105</a><br></div><div><br></div><div>&quot;<span style="color:rgb(34,36,38);font-family:Arial,&#39;Helvetica Neue&#39;,Helvetica,sans-serif;font-size:15px;line-height:17.7273px">For instance, the following code shows that the &quot;do-while&quot; is a bit faster. This because the &quot;jmp&quot; istruction is not used by the &quot;do-while&quot; loop.</span>&quot;</div><div><br></div><div><pre class="lang-c prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">int</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> main</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">int</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> argc</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">char</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">*</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> argv</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[])</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     
</span><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">int</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">char</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">];</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  

</span><span class="com" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">//&quot;FOR&quot; LOOP:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> 
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  

</span><span class="com" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">//&quot;WHILE&quot; LOOP:  </span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">while</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  

</span><span class="com" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">//&quot;DO-WHILE&quot; LOOP:  </span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">do</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">while</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  

</span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">return</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(34,36,38);font-family:Arial,&#39;Helvetica Neue&#39;,Helvetica,sans-serif;line-height:17.7273px"><strong style="margin:0px;padding:0px;border:0px">// &quot;FOR&quot; LOOP:</strong></p><pre class="lang-c prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013C8</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013CF</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jmp         wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">3Ah</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">10013DAh</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     

  </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013D1</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> UPDATE i 
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013D4</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  add         eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013D7</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">eax   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013DA</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  cmp         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">64h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> TEST  
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013DE</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jge         wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">4Ah</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">10013EAh</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> COND JUMP   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013E0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> DO THE JOB</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">..</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013E3</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         byte ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">78h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013E8</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jmp         wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">31h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">10013D1h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">     </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> UNCOND JUMP 
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(34,36,38);font-family:Arial,&#39;Helvetica Neue&#39;,Helvetica,sans-serif;line-height:17.7273px"><strong style="margin:0px;padding:0px;border:0px">// &quot;WHILE&quot; LOOP:</strong></p><pre class="lang-c prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
  </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013EA</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
  </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">while</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013F1</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  cmp         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">64h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> TEST
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013F5</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jge         wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">6Ah</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100140Ah</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">      </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> COND JUMP 
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013F7</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> DO THE JOB</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">..</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013FA</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         byte ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">78h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">010013FF</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         ecx</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> UPDATE i 
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001402</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  add         ecx</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001405</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ecx   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001408</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jmp         wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">51h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">10013F1h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">      </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> UNCOND JUMP
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(34,36,38);font-family:Arial,&#39;Helvetica Neue&#39;,Helvetica,sans-serif;line-height:17.7273px"><strong style="margin:0px;padding:0px;border:0px">// &quot;DO-WHILE&quot; LOOP:</strong></p><pre class="lang-c prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0100140A</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
  </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">do</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001411</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> DO THE JOB</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">..</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001414</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         byte ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">eax</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">78h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001419</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         ecx</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">]</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> UPDATE i
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0100141C</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  add         ecx</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0100141F</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  mov         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ecx   
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001422</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  cmp         dword ptr </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">[</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ebp</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0Ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">],</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">64h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> TEST
    </span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">01001426</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  jl          wmain</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">+</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">71h</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1001411h</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">      </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;&lt;&lt;</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> COND JUMP
  </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">while</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&lt;</span><span class="lit" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">100</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span></code></pre></div><div><br></div><div><br></div><div class="gmail_quote"><div dir="ltr">Em sex, 11 de dez de 2015 às 06:34, David Owens II via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I don’t know what you did, your gist 404s. </div><div><br></div><div>Here’s an update with the while-loop: <a href="https://gist.github.com/owensd/b438bea90075907fa6ec" target="_blank">https://gist.github.com/owensd/b438bea90075907fa6ec</a> and using both i and j within the loops. This is a simple OS X framework project with unit tests.</div><div><br></div><div><b>Debug Build:</b></div><div><ul><li>testZipStride - 2.496s</li><li>testCStyleFor - 0.210s</li><li>testWhileLoop - 0.220s</li></ul><div><div><b><br></b></div><div><b>Release Build:</b></div><div><ul><li>testZipStride - 0.029s</li><li>testCStyleFor - 0.018s</li><li>testWhileLoop - 0.019s</li></ul><div><br></div></div></div></div><div>I ran these tests from my MacBook Pro, the previous tests were from my iMac.</div><div><br></div><div>When you use the sum += (i - j) construct, I think all you are ending up with a hot-path that the optimizer can end up optimizing better (my guess is that the i-j turns into a constant expression - after all, the difference is always 1, but I don’t know enough about the SIL representation to confirm that). If you use a code path where that expression is not constant time (again, assuming my suspicion is correct), the zip+stride is against slower.</div><div><br></div><div>I would argue the following:</div><div><br></div><div><ol><li>The code is not objectively easier to read or understand with the zip+stride construct (arguably, they are not even semantically equivalent).</li><li>The debug builds are prohibitively slower, especially in the context of high-performance requirement code (I’m doing a lot of prototyping Swift in the context of games, so yes, performance matters considerably).</li><li>The optimized builds are still slower than the for-in “equivalent&quot; functionality.</li><li>The optimizer is inconsistent, like all optimizers are (this is a simple truth, not a value judgement - optimizers are not magic, they are code that is run like any other code and can only do as well as they are coded under the conditions they are coded against), at actually producing similar results with code that ends up with slightly different shapes.</li><li>There is not functionally equivalent version of the code that I can write that is not more verbose, while requiring artificial scoping constructs, to achieve the same behavior.</li></ol></div><div><br></div><div>So no, there is no evidence that I’ve seen to reconsider my opinion that this proposal should not be implemented. If there is evidence to show that my findings are incorrect or a poor summary of the general problem I am seeing, then of course I would reconsider my opinion.</div></div><div style="word-wrap:break-word"><div><br></div><div>-David</div></div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 10, 2015, at 9:12 PM, Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com" target="_blank">cantrell@pobox.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div>Hold the presses.</div><div><br></div><div>David, I found the radical differences in our results troubling, so I did some digging. It turns out that the zip+stride code:</div><div><br></div><div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    <span style="color:#323e7d">var</span> sum = <span style="color:#323e7d">0</span></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    <span style="color:#323e7d">for</span> (i, j) <span style="color:#323e7d">in</span> <span style="color:#587ea8">zip</span>(<span style="color:#587ea8">first</span>.<span style="color:#587ea8">stride</span>(to: <span style="color:#323e7d">0</span>, by: -<span style="color:#323e7d">1</span>), <span style="color:#587ea8">second</span>.<span style="color:#587ea8">stride</span>(to: <span style="color:#323e7d">0</span>, by: -<span style="color:#323e7d">2</span>)) <span style="font-size:10.5px">{</span></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">        <span style="color:#323e7d">if</span> i % <span style="color:#323e7d">2</span> == <span style="color:#323e7d">0</span> { <span style="color:#323e7d">continue</span> }</div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">        sum += <span style="color:#323e7d">1</span></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    }</div></div><div><br></div><div>…runs <i>much</i> faster if you actually use both i and j inside the loop:</div><div><br></div><div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    <span style="color:#323e7d">var</span> sum = <span style="color:#323e7d">0</span></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    <span style="color:#323e7d">for</span> (i, j) <span style="color:#323e7d">in</span> <span style="color:#587ea8">zip</span>(<span style="color:#587ea8">first</span>.<span style="color:#587ea8">stride</span>(to: <span style="color:#323e7d">0</span>, by: -<span style="color:#323e7d">1</span>), <span style="color:#587ea8">second</span>.<span style="color:#587ea8">stride</span>(to: <span style="color:#323e7d">0</span>, by: -<span style="color:#323e7d">2</span>)) {</div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo"><span style="font-size:10.5px">        </span><span style="font-size:10.5px;color:rgb(50,62,125)">if</span><span style="font-size:10.5px"> i % </span><span style="font-size:10.5px;color:rgb(50,62,125)">2</span><span style="font-size:10.5px"> == </span><span style="font-size:10.5px;color:rgb(50,62,125)">0</span><span style="font-size:10.5px"> { </span><span style="font-size:10.5px;color:rgb(50,62,125)">continue</span><span style="font-size:10.5px"> }</span></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">        sum += <b>i-j</b></div><div style="margin:0px;font-size:10.5px;line-height:normal;font-family:Menlo">    }</div></div><div><br></div><div>Weird, right? This is with optimization on (default “production” build). It smells like a compiler quirk.</div><div><br></div><div>With that tweak, the zip+stride approach actually clocks in faster than the C-style for. Yes, you read that right: <i>faster</i>. Also smells like a quirk. Am I doing something fantastically stupid in my code? Or maybe it’s just my idiosyncratic taste in indentation? :P</div><div><br></div><div>Here’s my test case, which was a command-line app with manual timing, followed by David’s dropped into the same harness, followed by David’s but with sum += i-j instead of sum += 1:</div><div><div><br></div><div>    <a href="https://gist.github.com/pcantrell/6bbe80e630d227ed0262" target="_blank">https://gist.github.com/pcantrell/6bbe80e630d227ed0262</a></div></div><div><br></div><div>Point is: <b>no big performance difference here; even a performance advantage</b> (that is probably a compiler artifact).</div><div><br></div><div>David and Thorsten, you might want to reconsider your reviews?</div><div><br></div><div>Results:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">—————— Paul’s comparison ——————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">zip+stride</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 0.519110977649689</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 0.503385007381439</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 0.503321051597595</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 0.485216021537781</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 0.524757027626038</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 0.478078007698059</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 0.503880977630615</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 0.498068988323212</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 0.485781013965607</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 0.524757027626038</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">C-style</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 0.85480797290802</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 0.879491031169891</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 0.851797997951508</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 0.836017966270447</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 0.863684952259064</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 0.837742984294891</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 0.839070022106171</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 0.849772989749908</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 0.819278955459595</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 0.863684952259064</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">Zip+stride takes 0.607579217692143x the time of C-style for</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">—————— David’s comparison ——————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">zip+stride</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 1.15285503864288</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 1.1244450211525</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 1.24192994832993</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 1.02782195806503</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 1.13640999794006</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 1.15879601240158</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 1.12114900350571</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 1.21364599466324</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 1.10698300600052</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 1.13640999794006</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">C-style</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 0.375869989395142</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 0.371365010738373</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 0.356527984142303</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 0.384984970092773</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 0.367590010166168</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 0.365644037723541</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 0.384257972240448</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 0.379297018051147</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 0.363133013248444</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 0.367590010166168</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">Zip+stride takes 3.09151491202482x the time of C-style for</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">—————— David’s comparison, actually using indices in the loop ——————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">zip+stride</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 0.328687965869904</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 0.332105994224548</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 0.336817979812622</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 0.321089029312134</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 0.338591992855072</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 0.348567008972168</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 0.34687602519989</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 0.34755402803421</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 0.341500997543335</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 0.338591992855072</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">C-style</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 0: 0.422354996204376</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 1: 0.427953958511353</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 2: 0.403640985488892</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 3: 0.415378987789154</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 4: 0.403639018535614</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 5: 0.416707038879395</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 6: 0.415345013141632</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 7: 0.417587995529175</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Iter 8: 0.415713012218475</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">         ——————————————</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  Median: 0.403639018535614</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">Zip+stride takes 0.838848518865867x the time of C-style for</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">Program ended with exit code: 0</div></div><div><br></div><div>Cheers,</div><div><br></div><div>Paul</div><div><br></div><div><blockquote type="cite"><div>On Dec 10, 2015, at 5:36 PM, David Owens II &lt;<a href="mailto:david@owensd.io" target="_blank">david@owensd.io</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div>Here’s my basic test case:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="Menlo">let first = 10000000</font></div><div><font face="Menlo">let second = 20000000</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">class LoopPerfTests: XCTestCase {</font></div><div><font face="Menlo">    </font></div><div><font face="Menlo">    func testZipStride() {</font></div><div><span style="font-family:Menlo">        </span><span style="font-family:Menlo">self</span><span style="font-family:Menlo">.</span><span style="font-family:Menlo">measureBlock</span><span style="font-family:Menlo"> {</span></div><div><font face="Menlo">            var sum = 0</font></div><div><font face="Menlo">            for (i, j) in zip(first.stride(to: 0, by: -1), second.stride(to: 0, by: -2)) {</font></div><div><font face="Menlo">                if i % 2 == 0 { continue }</font></div><div><font face="Menlo">                sum += 1</font></div><div><font face="Menlo">            }</font></div><div><font face="Menlo">            print(sum)</font></div><div><font face="Menlo">        }</font></div><div><font face="Menlo">    }</font></div><div><font face="Menlo">    </font></div><div><font face="Menlo">    func testCStyleFor() {</font></div><div><font face="Menlo">        self.measureBlock {</font></div><div><font face="Menlo">            var sum = 0</font></div><div><font face="Menlo">            for var i = first, j = second; i &gt; 0 &amp;&amp; j &gt; 0; i -= 1, j -= 2 {</font></div><div><font face="Menlo">                if i % 2 == 0 { continue }</font></div><div><font face="Menlo">                sum += 1</font></div><div><font face="Menlo">            }</font></div><div><font face="Menlo">            print(sum)</font></div><div><font face="Menlo">        }</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">    }</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">}</font></div></blockquote><div><br></div><div>Non-optimized timings:</div><div><ul><li>testCStyleFor - 0.126s</li><li>testZipStride - 2.189s</li></ul></div><div><br></div><div>Optimized timings:</div><div><div><ul><li>testCStyleFor - 0.008s</li><li>testZipStride - 0.015s</li></ul></div></div><div><br></div><div>That’s a lot worse than 34%; even in optimized builds, that’s 2x slower and in debug builds, that’s 17x slower. I think it’s unreasonable to force people to write a more verbose while-loop construct to simply get the performance they need.</div><div><br></div><div>Also, the readability argument is very subjective; for example, I don’t find the zip version more readability. In fact, I think it obscures what the logic of the loop is doing. But again, that’s subjective.</div><div><br></div><div>-David</div><div><br></div><div><blockquote type="cite"><div>On Dec 10, 2015, at 2:41 PM, Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com" target="_blank">cantrell@pobox.com</a>&gt; wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div style="word-wrap:break-word"><div><div>Is there any guarantee that these two loops have the exact same runtime performance?</div><div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="Menlo">for (i, j) in zip(10.stride(to: 0, by: -1), 20.stride(to: 0, by: -2)) {</font></div><div><font face="Menlo">   if i % 2 == 0 { continue }</font></div><div><font face="Menlo">   print(i, j)</font></div><div><font face="Menlo">}</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">for var i = 10, j = 20; i &gt; 0 &amp;&amp; j &gt; 0; i -= 1, j -= 2 {</font></div><div><font face="Menlo">   if i % 2 == 0 { continue }</font></div><span style="font-family:Menlo">   print(i, j)</span><div><font face="Menlo">}</font></div></blockquote><div><blockquote type="cite"></blockquote><blockquote type="cite"></blockquote></div></div></div></div></blockquote></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">In a quick and dirty test, the second is approximately 34% slower.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I’d say that’s more than acceptable for the readability gain. If you’re in that rare stretch of critical code where the extra 34% actually matters, write it using a while loop instead.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">P</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div>On Dec 10, 2015, at 4:07 PM, David Owens II via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 10, 2015, at 1:57 PM, thorsten--- via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Yes, performance is one thing neglected by the discussions and the proposal.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></blockquote></div><br><div>This is my primary objection to to this proposal; it assumes (or neglects?) that all of the types used can magically be inlined to nothing but the imperative code. This isn’t magical, someone has to implement the optimizations to do this.</div><div><br></div><div>Is there any guarantee that these two loops have the exact same runtime performance?</div><div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="Menlo">for (i, j) in zip(10.stride(to: 0, by: -1), 20.stride(to: 0, by: -2)) {</font></div><div><font face="Menlo">   if i % 2 == 0 { continue }</font></div><div><font face="Menlo">   print(i, j)</font></div><div><font face="Menlo">}</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">for var i = 10, j = 20; i &gt; 0 &amp;&amp; j &gt; 0; i -= 1, j -= 2 {</font></div><div><font face="Menlo">   if i % 2 == 0 { continue }</font></div><span style="font-family:Menlo">   print(i, j)</span><div><font face="Menlo">}</font></div></blockquote><div><blockquote type="cite"></blockquote><blockquote type="cite"></blockquote></div><div><br></div><div>And can you guarantee that performance is relatively the same across debug and release builds? Because historically, Swift has suffered greatly in this regard with respects to the performance of optimized versus non-optimized builds.</div></div><div><br></div><div>These types of optimizer issues are real-world things I’ve had to deal with (and have written up many blog posts about). I get the desire to simplify the constructs, but we need an escape hatch to write performant code when the optimizer isn’t up to the job.</div><div><br></div><div>-David</div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=zCg-2FSGF9Wk188a6c55kLyEbrj7YhaXxFEHM-2F-2B0YAlzVbqZGAg4i3SBvgPUw5uEFQbr8fEPwqqUFQb7VZ4tlBpU-2FZ9Wdcv90oH0fJ5jP-2Bd-2BnfAB5xQ-2FM8ILhQ3CMsUuyVyp8wO2XudWrUmtfVjPbV7-2FcRr-2F8nfR2mO0llGnjqSoJp9kM8-2FYGDP5kOXzyQ-2FlA6CTMKS3GoaGJ19o1vTnpVZE3I-2B2L-2FHgQNqIkOBllOTIE-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=fuWmDRE6-2FDdvdUHeLHruUfdigJaxz7nh99l6HfkulY-2BIV6CVmGB2Ay61MHOEDsu740KIVv-2F809RGFyhUWgyotsD5ojMfMScQ62SVlcsKy8cTv1hW5yTcoCzY5VDNHeOwphfmE7JjAB6oKuT3s4n1MOfTKKrXV3PEXBcGnem48V3TuoxI6MkgpYiXZaxPqH52JzeefmOuGVfxObJwuddHLIR6i00-2FqfoMLUiHXSTNZCc-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div></div>