Hi all,
I'm rewriting an application that produces lots of large integers. My
first version uses BigIntegers and writes them as decimal string to an
output file. To improve the performance, I implemented a second version
which uses long datatypes instead of BigIntegers, and
RandomAccessFile's writeLong() function. But instead of improving the
performance, this second version is much slower than the first version.
What might be the reason for this unexpected behaviour?
Thanks for any hints,
Chris
PS: I'm using "java 1.4.2" from SUN.
Roedy Green - 09 Jan 2006 08:33 GMT
> But instead of improving the
>performance, this second version is much slower than the first version.
Conversion to and from decimal String will be faster with BigDecimal,
but I would expect everything else to be faster. Did you measure which
method was accounting for the difference?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Thomas Weidenfeller - 09 Jan 2006 08:35 GMT
> But instead of improving the
> performance, this second version is much slower than the first version.
>
> What might be the reason for this unexpected behaviour?
Get a profiler tool and measure where you have the performance problems.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Thomas Hawtin - 09 Jan 2006 15:57 GMT
> I'm rewriting an application that produces lots of large integers. My
> first version uses BigIntegers and writes them as decimal string to an
> output file. To improve the performance, I implemented a second version
> which uses long datatypes instead of BigIntegers, and
> RandomAccessFile's writeLong() function. But instead of improving the
> performance, this second version is much slower than the first version.
How many digits in your numbers? Discs tend to be slower than
processors. If the second version produces a larger file, then it
shouldn't be too surprising that it can be slower.
On the other hand, now that I look at RandomAccessFile it appears
hideously inefficient for this sort of operation. writeLong involves
eight native method calls. I suggest only using bulk operations on
RandomAccessFile, if performance is a concern.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/