wood burning stoves 2.0*
The moose likes Features new in Java 7 and the fly likes Is Java 7 faster than ancient versions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "Is Java 7 faster than ancient versions?" Watch "Is Java 7 faster than ancient versions?" New topic
Author

Is Java 7 faster than ancient versions?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
I'd like to know if Java 7 is faster than ancient versions.

Thank you


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Java 7 is a language. It makes no sense to say it's faster or slower than other versions.

Oracle's new JVM might be faster than older versions, but I could write a JVM for Java 7 that runs old code slower than Sun's 1.1 version.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

If you're asking about the Sun / Oracle Java implementations, then yes, Oracle's Java 7 JVM is certainly faster than older versions. In each new Java version from Oracle there are new optimizations and other performance improvements.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jennifer Reese
author
Greenhorn

Joined: Mar 08, 2012
Posts: 8
It is true there are improvements in the performance of the JVM with each release. However, the new features of Java 7 are intended to help you improve the maintainability and efficiency of your applications. This could in turn result in more reliable and possibly faster execution. For example, in our book we discuss the ThreadLocalRandom class. This class, when used in place of the older Random class, will improve the performance of your threads.

Also, don't forget the javac compiler has a -O option that will result in the compiler optimizing the compiled code.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Jennifer Reese wrote:Also, don't forget the javac compiler has a -O option that will result in the compiler optimizing the compiled code.

No, it doesn't. And if it does, then it's not in the documentation.

The Java compiler (javac) doesn't do a lot of optimization. The JIT compiler that's part of the JVM on the other hand, does a lot of very sophisticated optimizations when it compiles the Java byte code to native machine code.

There's a reason why javac doesn't optimize. By not doing a lot of optimization, javac makes it easier for the JIT to generate optimized native machine code.
Jennifer Reese
author
Greenhorn

Joined: Mar 08, 2012
Posts: 8
Oops, you're right! As of 1.3, the -O has been deprecated and should not be used. In earlier releases, it would inline static, final and private methods to attempt to speed up your code.

For many applications, fine tuning JVM options is not really necessary, but if you are curious, here is an interesting article about some current options for improving JVM performance.
http://randomlyrr.blogspot.com/2012/03/java-tuning-in-nutshell-part-1.html

Also, just some general techniques to use to help the JVM handle your code in the optimal manner:
https://wikis.oracle.com/display/HotSpotInternals/PerformanceTechniques
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37985
    
  22
Jennifer Reese wrote:Oops, you're right! As of 1.3, the -O has been deprecated and should not be used. In earlier releases, it would inline static, final and private methods to attempt to speed up your code. . . .
Presumably using JIT techniques works a lot better than trying inlining.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Inlining is one of the optimizations that the JIT compiler does. Probably it works a lot better if javac leaves it to the JIT, so that's why they took it out of javac since version 1.3.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Java 7 faster than ancient versions?
 
Similar Threads
WA #1.....word association
JDK 6 vs JDK 7
Performance of JVM of J2SE1.4, Java5, Java6
Jboss not starting
Windows 7 seems to be worth it