in reply to Re^2: code optimization
in thread code optimization
Yes, I think the C version would however be faster by some factor not depending on the input size. That's because Perl has some overhead because of the data structures it uses, because of the garbage collection and so forth. There's also the silly version of comparing a/b < c/d by multiplying everything with bd then you reach ad<cb. Now, are two multiplications faster than a division, even if the multiplication is carried out with Karatsuba's algorithm (the article says that "Karatsuba is usually faster when the multiplicands are longer than 320–640 bits" and also gives complexity) or linear time multiplication ? I'm just wondering what the cost of a normal division is in relation to the cost of two multiplications..
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: code optimization
by BrowserUk (Patriarch) on Nov 04, 2011 at 13:15 UTC | |
by spx2 (Deacon) on Nov 04, 2011 at 14:08 UTC | |
by BrowserUk (Patriarch) on Nov 04, 2011 at 14:31 UTC | |
by spx2 (Deacon) on Nov 04, 2011 at 15:27 UTC | |
by BrowserUk (Patriarch) on Nov 04, 2011 at 16:10 UTC |
In Section
Seekers of Perl Wisdom