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 / December 2007

Tip: Looking for answers? Try searching our database.

Speed

Thread view: 
Kenneth P. Turvey - 05 Dec 2007 02:09 GMT
I've written some code and it is running much slower than I would like it
to.  I'm from the C school of optimization which says that you write the
code the best way you can and then when you get done you run it through a
profiler to get the optimization done.  This has always served me well in
the C world.  To paraphrase Knuth, "Premature optimization is the root of
all evil."  

So this has been the philosophy I've used in Java as well, but now it just
doesn't seem to be serving me well.  The profiler isn't showing any really
hot spots that need work (which was quite surprising) and it shows only a
very small amount of time being used in garbage collection.  Yet the code
is much, much slower than other implementations in C or C++.  

So what is the best procedure for getting performance from a Java
application?  

Thanks.  

BTW, I'm using the profiler that comes with NetBeans.  

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Arne Vajhøj - 05 Dec 2007 02:13 GMT
> I've written some code and it is running much slower than I would like it
> to.  I'm from the C school of optimization which says that you write the
[quoted text clipped - 11 lines]
> So what is the best procedure for getting performance from a Java
> application?  

Your procedure looks fine.

Even though there are no hotspots, then it must obviously spend
somewhere.

Try look at the code.

Possible post some code snippts for comments and suggestions
for improvement.

Arne
Zig - 05 Dec 2007 02:46 GMT
> I've written some code and it is running much slower than I would like it
> to.  I'm from the C school of optimization which says that you write the
[quoted text clipped - 17 lines]
>
> BTW, I'm using the profiler that comes with NetBeans.

Not sure about the NetBeans profiler, but time your app without the  
profiler, and again with the profiler. If those figures don't look  
similar, you may have too much instrumentation turned on in the profiler.

GC time is usually pretty small until the heap utilization starts getting  
high. But, some profilers will break "allocation time" seperately from  
"runnable time" (likewise for I/O wait, wait, blocked). So, if your  
algorithm takes 15 seconds, and the time spent in java.lang.Thread.run()  
(or MyClass.main(String[]) ) is less than 15 seconds, then your profiler  
is hiding something.

HTH,

-Zig
bugbear - 05 Dec 2007 09:39 GMT
> I've written some code and it is running much slower than I would like it
> to.  I'm from the C school of optimization which says that you write the
[quoted text clipped - 11 lines]
> So what is the best procedure for getting performance from a Java
> application?  

Hmm. My "guess" (on the minimal information you provide) is
that something "global" to your application is slow.

This could either be "the JVM" (i.e. language overhead)
or the "core" datastructure. If this is accessed from
every part of your code, you would get the results
you describe.

Without more detail, I can't say more.

Oh, except possibly, concentrate on "big O" optimisations
first, but I infer that you know that.

  BugBear
Mark Space - 05 Dec 2007 17:14 GMT
> BTW, I'm using the profiler that comes with NetBeans.  

If you post up what the profiler says (maybe a snapshop after running
one "slow" algorithm) folks can take a poke at it.  I'm always
interested in debuggin/speed techniques.


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.