Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

writeLong() performance

Thread view: 
Chris - 08 Jan 2006 09:53 GMT
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/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.