Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: The golf course looks great... (Part II) ("speed")

by tye (Cardinal)
on May 27, 2009 at 13:07 UTC ( #766401=note: print w/ replies, xml ) Need Help??


in reply to Re: The golf course looks great, my swing feels good, I like my chances (Part II)
in thread The golf course looks great, my swing feels good, I like my chances (Part II)

I chose the "19&" version of a magic formula here only because the bitwise and & operator is typically faster than the modulo % operator. BTW, an interesting (non-golf) problem is to find the most efficient magic formula: for that, I expect you'd try to use "fast" operators (such as &, ^, |, >>), while avoiding "slow" ones (such as % and /).

Your criteria probably make sense if you are writing C code. I doubt they make sense when writing in any of the languages you are actually writing in.

In particular, in Perl your fastest formula is going to be the one with the fewest operations. Dispatching a Perl opnode is going to be (I'm guessing) two or three orders of magnitude slower than even something "slow" like a division machine-language instruction.

- tye        


Comment on Re^2: The golf course looks great... (Part II) ("speed")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://766401]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-07-30 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (237 votes), past polls