Skip to content

Instantly share code, notes, and snippets.

@gmilby
Created July 19, 2013 22:40
Show Gist options
  • Save gmilby/6042881 to your computer and use it in GitHub Desktop.
Save gmilby/6042881 to your computer and use it in GitHub Desktop.
speed tests for "for loops"
Syntax A - 0.25367754 seconds
for($i=0; $i<1000000; $i++){}
Syntax B - 0.25415988 seconds
for($i=0; $i<=999999; $i++){}
Syntax C - 0.25957097 seconds
for($i=0; $i!=1000000; $i++){}
Syntax D - 0.25594527 seconds
for($i=1000000; $i>0; $i--){}
Syntax E - 0.25266805 seconds
for($i=1000000; $i>=1; $i--){}
Syntax F - 0.25876847 seconds
for($i=1000000; $i!=0; $i--){}
Syntax G - 0.17032199 seconds
for($i=1000000; $i; $i--){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment