in reply to Re^4: Why is this code so much slower than the same algorithm in C? (2s)
in thread Why is this code so much slower than the same algorithm in C?

Why do that much analysis and then throw away so much speed by not using a lexical? Also why not finish the analysis?
perl -le 'my $i = 0;do { $i += 20 } while( $i%46558512 ); print $i' 232792560
Performance is essentially the same if you write 46558512 as (9*7*11*13*16*17*19).
  • Comment on Re^5: Why is this code so much slower than the same algorithm in C? (2s)
  • Download Code

Replies are listed 'Best First'.
Re^6: Why is this code so much slower than the same algorithm in C? (why)
by tye (Sage) on Dec 16, 2008 at 02:55 UTC

    My first script takes 2 seconds to run so I doubt you can type "my $i = 0;" faster than the running time you'd save. "That much analysis"? I did hardly any. And I believe my second one-liner already trumps either of your contributions. q-:

    - tye        

      Can you type that in under 0.5 s? If so, then the my is a win. And in the thread you previously discussed having talked about it in chatter and corrected 2 mistakes. I took that as a sing that you did some analysis.

      I don't remember the second one-liner. It is obviously faster, but doesn't fit with the theme of trying to micro-optimize the loop.