I am currently doing some performance tests on Hibernate / Hibernate.Search with Lucene in Java and the pendent in C#. Currently I am using the newest releases of both versions.
I had some interesting results in the tests but what i am now doing is to find some performance tests or better some explanation of possible performance differences in both languages.
For example: What I know is that ge开发者_JS百科nerics in C# are more efficient because they don't use boxing at runtime because they are type-safe. Furthermore two different Lists with referenced types can share the JIT-Code in C#. So in C# there is now boxing-overhead. (knowledge came from this article)
This is an example I searched for.
But I would like to know if there are more differences in those two language that could cause performance differences. But I need some references as well, since these test will be summarised in a scientific paper.
I have found many papers / books about differences, but not much about performance differences in specific shared features of those two languages.
But important to say is that I am not just searching for some tests that are made but also deeper explanations why one languages is faster than the other in that feature.
Thanks for any hints and help!
C# language contains many more abstractions and that, theoretically, can make the compiler/plataform understand more what the programmer wants, and then apply more optimizations, like the one you mentioned about statically type-safe generics.
On the other hand, platform maturity is very important. JVM is usually much faster than .NET runtime because garbage collection and optimization are much more sophisticated and evolved in Java than in .NET, as of today. Even in the absense of good language abstractions, a platform can identify program patterns and optimize accordingly.
But because they are similar in nature and use similar architectures, when deciding between C# or Java, performance is a very small issue. Normally when one have performance problems, he/she can select other algorithms, perform tunning or simply use better hardware.
If you want to write a paper about language performance, I suggest you include C++ and talk about code optimization to better use hardware resources (such as special instructions), because these is what produce top performance today. Libraries can have assembly-crafted routines to squeeze CPU for some mass data operations. Interpreted languages can make more load-specific and hardware-specific optimizations, but that said, the remaining optimizations are pretty much the ones of static code analysis.
http://en.wikipedia.org/wiki/Program_optimization
Any comparison of performance of languages is just a speculation by definition.
Performance of Java and C# application depends on a lot of features. First of all it depends on VMs which run the applications. So you are comparing two different virtual machines for different languages. But there is still difficulties just in comparing Java virtual machines.
So the right question is "what differences between those VMs and implementation of some common libraries". And my answer is "A LOT".
精彩评论