This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: effectiveness of gnu.math
2008/1/27, Per Bothner <per@bothner.com>:
> Thanks! I took a look at things, and now I get the same results you do.
> I.e. gnu.math.IntNum multiplication is more efficient than BigInteger
> multiplication. I think one reason for that is that IntNum is more
> efficient when the numbers fits in a single 'int'.
Hmm, small check:
(define (speed-check max-number)
(do ((i 10000 (+ i 10000)))
((> i max-number))
(let* ((bi ((as <gnu.math.IntNum> i):asBigInteger))
(ti (time (!il i)))
(tbi (time (!bil bi))))
(format #t "~A - <integer> time ~,3F sec., <BigInteger> time
~,3F sec., <integer> faster by ~,1F%\n"
i ti:Duration tbi:Duration (* (- 1 (/ ti:Duration
tbi:Duration)) 100)))))
where `time` - my macro
result of (speed-check 70000):
10000 - <integer> time 0.500 sec., <BigInteger> time 0.860 sec.,
<integer> faster by 41.9%
20000 - <integer> time 2.203 sec., <BigInteger> time 3.672 sec.,
<integer> faster by 40.0%
30000 - <integer> time 5.125 sec., <BigInteger> time 8.750 sec.,
<integer> faster by 41.4%
40000 - <integer> time 9.579 sec., <BigInteger> time 16.625 sec.,
<integer> faster by 42.4%
50000 - <integer> time 16.484 sec., <BigInteger> time 28.766 sec.,
<integer> faster by 42.7%
60000 - <integer> time 25.484 sec., <BigInteger> time 44.860 sec.,
<integer> faster by 43.2%
70000 - <integer> time 36.813 sec., <BigInteger> time 65.219 sec.,
<integer> faster by 43.6%
Is this the trend?
--
WBR, Yaroslav Kavechuk.