• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java performance measurements

 
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a big Java fan and do all my development in Java / JavaScript. I'd like to be enough of an expert to know the limits and not be blindly stupid about it. For that, I want to know what up to date performance measurements are available and where to find them. The last time I found tables of good benchmark comparisons between Java and other languages, I ended up saying (generalizing) that Java is great for most things, well designed for web (and generally any distributed - what's not nowadays?) as well as many more kinds of applications. But if you are building a mathematically intensive program (I've been involved with some that include a huge number of iterations in operation - like you'd build to do benchmarking) you're better off with C/C++. But that's based on benchmarks from years ago. I'd like to get up-to-date.

Surely, there are some credible and reasonably sets of test results out there, somewhere? Sun (Oracle) must have run tests on Java. And whoever is responsible for improvements in C/C++ must be making measurements. Does anyone know where I can find them?

 
Roger F. Gay
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I'm totally striking out on this question. I posted in another forum and it was struck for being too vague. "Odd thing that," I thought. In the past, I've seen performance measures, based on benchmark tests for a wide range of computer languages. I thought everyone would immediately understand what I was looking for.

So, it looks like I may be so out of touch on this topic that I'm not connecting with modern culture.

Rather than ask where are they? Let me ask about your experience with them - whatever you have. It doesn't matter if you have a little or a lot. Just give me a hint. Do you do your own? Do companies not care about such measurements on the basics of languages and just test for final system results? Has everyone stopped caring?

Anything. I'm just hangin' out here.
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say it's rare that the performance of the language makes all the difference. C apps can run slow or fast, just as Java apps can run slow or fast. Java is fast enough these days that it can be considered for implementing just about any algorithm. So I'd say the choice of language is driven much more by other considerations than by raw single-CPU speed.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Comparing programming languages for performance isn't really a valid comparison. It's a little bit like comparing the speed of cars based on their color.

How fast a program runs is in principle not determined by the language it is written in, but rather by the quality of the compiler or runtime environment for that language. There are some aspects of programming languages that can have an impact on how easy or hard it is to make an efficient compiler or runtime environment. For example, it's harder to make dynamically typed languages run fast, because the language requires that runtime checks are done that wouldn't be necessary for a statically typed language. But on the other hand many tricks and sophisticated optimizations have been invented to solve such problems.

So, choosing one programming language over another because you think it is faster is like choosing a red car instead of a blue car because you think that red cars are faster.

Long ago Java had a stigma of being slow, but the optimizations in the JVM, especially the JIT compiler, are now so sophisticated that it is really not slow at all anymore; it can even do some dynamic optimizations that make it in principle produce more efficient native code than what could be done with an ahead-of-time compiler (such as a normal C or C++ compiler).
 
Roger F. Gay
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Long ago Java had a stigma of being slow, but the optimizations in the JVM, especially the JIT compiler, are now so sophisticated that it is really not slow at all anymore; it can even do some dynamic optimizations that make it in principle produce more efficient native code than what could be done with an ahead-of-time compiler (such as a normal C or C++ compiler).



I mentioned being a Java fan as part of the question - hinting subtly that I know it's fast now. (I even, very happily, use string case variables in Java 7 for switch case.) I do sometimes have some time sensitive components in applications - you know, the kind you don't just do once but do 100s of millions of times over and over again. Especially in real-time systems it matters. But you're right about the other thing too. I suppose I should do my own custom performance checks at least on something representing the critical repetitious part of the algorithm rather than relying on somebody else's benchmarks.

BTW: I've just built a server that requires lots of cryptic stuff for security when making a connection and a bit more with each message. On localhost, the entire echo process test (what we all do first when we build servers) seems instantaneous. Java is fast. (Even says good things about the speed of Firefox and Chrome.)
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roger F. Gay wrote:I mentioned being a Java fan as part of the question - hinting subtly that I know it's fast now.


But do you realize just how fast? I've created a Stopwatch class that allows me to get average timings over multiple invocations, and have been quite amazed at the stuff that comes in consistently under 5ns - including things with method calls - and that's on a 4 year-old workhorse Dell.
My reckoning is that Java compilers are getting so smart that you simply can't rely on the fact that what you coded (eg, a method call) is what's actually getting run.

That said, there are some things that are beyond the scope of the language, just one of which is the ability to make use of CAS (compare and swap) operations. Many of the new 'Atomic' and 'Lock' classes do exactly that, but under the hood there's some native (I suspect C or C++) code behind it...Oh, and BTW, they are blisteringly fast .

Winston
 
Roger F. Gay
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody have an opinion on this performance comparison? Android 1.5 speed comparing C++, C# (mono) and Java (using Roozz plugin)

I haven't been working with cell phones and am not sure it's an apples to apples comparison; but he seems to be saying that Java is really slow compared to C# and C++.

BTW: I didn't come up with this one myself (just to cause trouble or anything). It was posted in response to a performance question on researchgate.net. Maybe I'm being suspicious here, but it seems short-sighted not to have a general set of performance measures to counter biased and misinformation that we know will come from Apple and Microsoft advocates. I'm just sayin' .... while wondering what the market is for programs that generate a large number of primes in a particular way; somehow making comparison between C++ and an alpha version of a Google toolset of some kind an important consideration.

 
reply
    Bookmark Topic Watch Topic
  • New Topic