This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: effectiveness of gnu.math
- From: "Yaroslav Kavenchuk" <kavenchuk at gmail dot com>
- To: "Per Bothner" <per at bothner dot com>
- Cc: kawa at sourceware dot org
- Date: Sat, 26 Jan 2008 23:49:29 +0200
- Subject: Re: effectiveness of gnu.math
- References: <4799A544.9040902@gmail.com> <479A216B.4040506@bothner.com>
2008/1/25, Per Bothner <per@bothner.com>:
> I'd love to find out what is going on. Would you mind trying to
> run some profiling tool (e.g. http://profiler.netbeans.org/)
> to see where the <integer> version is spending its time?
> I used the code at the end of this message, and compiled it with -C,
> and then tried:
>
> $ time /opt/jdk1.5/bin/java kawa.repl -e '(require <foo>)' -e '(il 20000)'
>
> vs
>
> $ time /opt/jdk1.5/bin/java kawa.repl -e '(require <foo>)' -e '(il
> (java.math.BigInteger:valueOf 20000))'
$ time kawa -e '(require <factorial>)' -e '(define x (!il 20000))'
real 0m2.937s
user 0m0.045s
sys 0m0.077s
$ time kawa -e '(require <factorial>)' -e '(define x (!bil
(java.math.BigInteger:valueOf 20000)))'
real 0m4.453s
user 0m0.061s
sys 0m0.093s
$ time kawa -e '(require <factorial>)' -e '(define x (!il 50000))'
real 0m17.640s
user 0m0.061s
sys 0m0.077s
$ time kawa -e '(require <factorial>)' -e '(define x (!bil
(java.math.BigInteger:valueOf 50000)))'
real 0m29.968s
user 0m0.045s
sys 0m0.093s
profiling results of
'(define x (!bil (java.math.BigInteger:valueOf 50000)))'
'define x' is need for disable of big number output
All threads - 43411 ms
main - 43404 ms
factorial.$ExBil (java.math.BigInteger) - 42293 ms (97,4%)
java.math.BigInteger.multiply (java.math.BigInteger) - 41657 ms (96%)
java.math.BigInteger.multiplyToLen (int[], int, int[], int, int[])
- 31293 ms (72,1%)
java.math.BigInteger.trustedStripLeadingZeroInts (int[]) - 10049 ms (23,2%)
profiling results of '(define x (!il 50000))'
All threads - 25342 ms
main - 25337 ms
factorial.$ExIl (gnu.math.IntNum) - 24178 ms (95,4%)
gnu.kawa.functions.MultiplyOp.applyN (Object[]) - 21903 ms (86,4%)
gnu.math.IntNum.times (gnu.math.IntNum, gnu.math.IntNum) - 21504 ms (84,9%)
gnu.math.IntNum.alloc (int) - 10748 ms (42,4%)
gnu.math.MPL.mul_1 (int[], int[], int, int) - 10168 ms (40,1%)
gnu.kawa.functions.AddOp.applyN (Object[]) - 1221 ms (4,8%)
code:
(define (!il x :: <integer>) :: <integer>
(do (((i :: <integer>) x (- i 1))
((k :: <integer>) 1 (* k i)))
((i:equals 1) k)))
(define (!bil x :: <java.math.BigInteger>) :: <java.math.BigInteger>
(do (((i :: <java.math.BigInteger>) x (i:subtract java.math.BigInteger:ONE))
((k :: <java.math.BigInteger>) java.math.BigInteger:ONE (k:multiply i)))
((i:equals java.math.BigInteger:ONE) k)))
Ah, java version:
$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b23)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode, sharing)
--
WBR, Yaroslav Kavenchuk.