Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java 8 speed

 
Grega Leskovšek
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the overall speed improvement from Java 7 to 8? And what from Java 6 to 8? Thanks, Gregor
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
… and does that differ from JVM to JVM; is there any difference between HotSpot and OpenJDK, for example?

And is there actually any difference between HotSpot and OpenJDK?
 
Cay Horstmann
author
Ranch Hand
Posts: 172
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid I am not a performance expert, and I really can't tell you whether you are getting a performance boost by going to Java 8. What matters more to me is that I can more easily write concurrent code on Java 8 than on Java 7, and that means I take advantage of the cores that I already paid for.

OpenJDK and Hotspot are pretty identical, except for some non-free bits (such as font rendering), and I never heard of any great speed differences between the two. But it's not my area of expertise.

Cheers,

Cay
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This blog did a benchmark. The results were:

Java 1.6 Java 1.7 Java 1.8
Test 1 3564ms 3653ms 3614ms
Test 2 27265ms 28773ms 28326ms
Test 3 6220ms 6579ms 6231ms
Test 4 408ms 428ms 423ms
Test 4 (parallelSort) 193ms
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks to me like the same speed throughout.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Looks to me like the same speed throughout.

Java 7 is higher, but not significantly. I think the key point in the benchmark is that parallelization is faster (presuming you have multiple cores)
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15715
73
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcourse, you shouldn't assume that a few little tests from one blog article prove that Java 6, 7 and 8 run at the same speed in general. There might be specific areas where improvements have been made that these tests don't show. There can also be significant differences between the 32-bit and 64-bit implementations of the JRE.

Note that lambda expressions should be more efficient than using anonymous inner classes. When you use an anonymous inner class, the JVM has to create an instance of the anonymous inner class. Lambda expressions compile to extra methods (generated by the compiler from the lambda expression). The overhead is just a method call; no instance of an anonymous inner class has to be instantiated. I've seen a talk by Brian Goetz (the lead of the Project Lambda project at Oracle) where explains in detail what options they looked at for implementing lambdas and how exactly it all works under the hood, where he explained this and many more details.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote: I think the key point in the benchmark is that parallelization is faster (presuming you have multiple cores)


Does anything not have multiple cores these days? Cool cellphones have had quad cores for years. There are even microcontrollers (like in an arduino) that are multi-core.

A better way to phrase it is that code that is designed for parallel processing is often faster on a multi-core machine. Java pre-7 was very challenging to write parallel code. Java 8 brings some nice features, but I expect it will be many years before mainstream commercial programmers use them.

I'd love to be wrong on this.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrell wrote:
Jeanne Boyarsky wrote: I think the key point in the benchmark is that parallelization is faster (presuming you have multiple cores)


Does anything not have multiple cores these days?

Really old computers, but that's not what I was thinking of with my statement. I was thinking "presuming you have multiple cores available to your program." Which isn't a given. You could be running in a sandbox. Or already be parallelizing for different users across cores. Or be maxed out on threads/cores. (I"m not sure exactly which of these scenarios constrains you, but I imagine at least one does.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!