Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance of JVM of J2SE1.4, Java5, Java6

 
Tejas Jain
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which one gives the best performance for the same java code (I mean not using the new features in Java 5&6)?
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that is a tricky question.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no facts to prove my statement, but I'd say the JVM becomes better and faster after each version, so if I had to guess it would be Java6.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a link: Java SE 6 - Improvements to Program Execution Speed

In general, newer versions of Sun's Java implementation are faster than older ones, sometimes a lot faster.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Especially multi-thread performance has improved tremendously between Java 1.4 and Java 6 (meaning lock contention, synchronization etc. have much less of an impact than they used to).
 
Daniel Chemko
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my own codebase, I did some profiling and found that dealing with the reflections API, I've found timing as:
Java 1.4.2 - 10
Java 1.5.0 - 5
Java 1.6.0 - 4

So yes, the newer JVM's perform much better than previous releases doing the same thing. The GUI will get some interesting optimizations from 1.6 onward since they're no longer doing Swing/AWT work on a single thread. This can possibly run into races if you're doing GUI work on other threads, so watch out for that. Also, 1.6+ has greatly improved the performance of graphics in pretty much every conceivable way. The same code should run significantly faster.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Chemko wrote:The GUI will get some interesting optimizations from 1.6 onward since they're no longer doing Swing/AWT work on a single thread.

Really? Can you please Quote Your Sources? Because as far as I know, there is still only one Event Dispatcher Thread.
It is made easier to handle threading in Swing with SwingWorker, but all GUI related code still must be executed on the EDT.
 
Daniel Chemko
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Really? Can you please Quote Your Sources? Because as far as I know, there is still only one Event Dispatcher Thread.
It is made easier to handle threading in Swing with SwingWorker, but all GUI related code still must be executed on the EDT."

Caught my ambiguity. I ran into several errors when dealing with my code, and when running through a debugger, EDT based errors were automatically suspended on the last stack entry "EventDispatchThread.run() line: 156".

If several errors are queued up, the debugger will list all the EDT's that generated the error. The problem was that the EDT was being regenerated after each error giving the false impression that they were running independently. Thanks for the catch.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic