BREAK the FOR VS WHILE loop war

PHP Benchmark - For vs While from John's PHP Digest starts the FOR VS WHILE argument again.
For VS While was already a topic in the old days:
Bruesoft's real time benchmark on loops changes result each request. Cosmin Budinschi's test show WHILE is faster than FOR.

I believe this is an endless fight, but I'm in the WHILE's side.

WHILE is FASTER! and USE LESS MEMORY

I have to support it with one of the best method ever(found out 3 days ago)
Screencast!

BTW if you can't see it, check out the revver page where my screencast is shown.

In this screencast, you will see that WHILE is slightly faster and it uses less memory!


Comments

Anonymous's picture

just curios

Yep for is faster than while... i didn't like while, but sometimes it goes just better :)

P.S. what editor you use in screencast?

Mgccl's picture

the editor is Emeditor The

the editor is Emeditor
The free edition is nice... but the pro is amazing...
It's popular around Chinese community because it's nice support of non-English characters.
but it can be slow when working with super large files(like... 50MB.. but really... why open something that big...)
I saw sublime text on your blog... neat stuff... thumbnail view of the document is a first in text editors...

Anonymous's picture

Pingback

[...] quick search for “for vs while php” landed me on Mgccl’s blog, where last year, he had tested and benchmarked exactly this with a lovely little [...]

Anonymous's picture

Optimized out

The $a is never being used after the loop, so it may just get optimized out.

Post new comment

  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <fn>
  • Lines and paragraphs break automatically.
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Mathematical equations and graphs can be added between [tex] and [/tex], [graph] and [/graph] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

Honey Pot that kill bots