Benchmark cannot "know" what my hypothetical "good" compiler would do.

And? It shows what *any* non hypothetical, can compile code now, real world useful compiler can do. Out in the real world hypothetical compilers producing theoretical code are less that totally useful. The results presented were for CL.EXE /O2 on a Win2K AMD K7 system. FWIW GCC does a significantly worse job of optimising the recursive code.

By all means compile it with anything you like on any platform and present any evidence that supports your hypothesis.

[root@devel3 root]# ./test.pl Benchmark: timing 1000000 iterations of iterative_c, iterative_p, recu +rsive_c, recursive_p... iterative_c: 1 wallclock secs ( 0.42 usr + 0.00 sys = 0.42 CPU) @ 2 +380952.38/s (n=1000000) iterative_p: 20 wallclock secs (18.34 usr + 0.00 sys = 18.34 CPU) @ 5 +4525.63/s (n=1000000) recursive_c: 1 wallclock secs ( 0.60 usr + 0.00 sys = 0.60 CPU) @ 1 +666666.67/s (n=1000000) recursive_p: 38 wallclock secs (37.75 usr + 0.00 sys = 37.75 CPU) @ 2 +6490.07/s (n=1000000) Rate recursive_p iterative_p recursive_c iterative_c recursive_p 26490/s -- -51% -98% -99% iterative_p 54526/s 106% -- -97% -98% recursive_c 1666667/s 6192% 2957% -- -30% iterative_c 2380952/s 8888% 4267% 43% -- [root@devel3 root]# gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)

cheers

tachyon


In reply to Re^5: Behold! The power of recursion. by tachyon
in thread Behold! The power of recursion. by DigitalKitty

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.