在Java虚拟机VS .NET CLR基准业绩 [英] Benchmarking Performance on Java VM vs .NET CLR

查看:125
本文介绍了在Java虚拟机VS .NET CLR基准业绩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你有过证明的选择上采用.NET,而不是基于Java的性能?

Have you ever had to justify the choice over using .NET instead of Java based on performance?

有关一种能够执行以下操作典型的高容量事务处理系统中,

For a typical high volume transaction processing system that can perform the following operations,

  • 在并发数据库事务
  • 在数学计算
  • 与其他Web服务(SOAP / XML,XML-RPC)
  • 互动

我的办法是在Java的JVM和C#的.NET CLR的基准下,各级负荷的上述操作code基准测试,并比较结果。

My approach would be to code benchmark tests in both Java for the JVM and C# for .NET CLR that benchmark the above operations under various levels of load and compare the results.

不谈,我兴趣听你将如何去这样做一个Java虚拟机之间确​​凿的性能对比语言和平台preferences .NET CLR?

Language and platform preferences aside, I am interested in hearing how you would go about doing a conclusive performance comparison between the Java VM and .NET CLR?

是否有存在的任何COM prehensive和尊重的基准?

Are there any comprehensive and respected benchmarks that exist?

推荐答案

我没有确切的数字在JVM VS CLR的效率,但不同的,如果有的话,很可能是小的。

I don't have exact numbers on the efficiency of the JVM vs the CLR, but the difference, if any, is likely to be small.

不过,在语言方面,C#中确实有一些低级别的结构比Java,这将允许更多的优化。

However, on the language side, C# does have some more low level constructs than Java, which would allow for more optimization.

结构,例如:

  • 用户定义的值类型。快速分配,没有内存开销(这是在这两个CLR和JVM每引用类型12个字节,如果我没记错的话)。有用的东西,让自己自然会pssed作为值前$ P $,如向量和矩阵。这样的数学运算。与联合这个裁判退出来避免这些大的值类型的过度复制。

  • User defined value types. Fast to allocate, no memory overhead (which is 12 bytes per reference type in both the CLR and JVM if I remember correctly). Useful for things that let themselves naturally be expressed as values, like vectors and matrices. So mathematical operations. Combine this with ref and out to avoid excessive copying of these large value types.

的code不安全块,允许多一点'接近金属'的优化。例如,虽然在CLR和JVM能够避免数组的边界在某些情况下检查,在很多情况下,他们不能和每个数组访问需要检查索引是否仍然在数组的边界。这里使用不安全code允许您访问数组的内存直接与指针和规避任何边界检查。这可能意味着一个显著储蓄。而在非常低的水平方面,另外还有 stackalloc ,它允许你直接在栈上分配的数组,而一个正常的数组在堆中分配,这是比较慢的,但也比较方便。我个人不知道 stackalloc 的任何实际应用。

Unsafe blocks of code that allow a little more 'close to the metal' optimization. For example, while the CLR and JVM can avoid array bounds checks in some situations, in a lot of cases, they can't and every array access requires a check whether or not the index is still within bounds of the array. Using unsafe code here allows you to access the memory of the array directly with pointers and circumvent any bounds checks. This can mean a significant saving. And on the very low level side, there's also stackalloc which allows you to allocate arrays directly on the stack, whereas a normal array is allocated on the heap, which is slower, but also more convenient. I personally don't know any practical applications of stackalloc.

真正的仿制药,不像擦除Java的泛型,避免不必要的铸造和拳击的类型。但是,如果这是在Java程序中的一个问题,它可以很容易地与一些额外的工作(例如从开关解决了的ArrayList<整数GT; 来在内部使用自定义类型一个 INT [] 缓冲区。)

True generics, unlike the type erasing generics of Java, avoiding unneeded casting and boxing. But if this is a problem in your Java program, it can easily be solved with some extra work (switching from for example a ArrayList<Integer> to a custom type that internally uses an int[] buffer.)

这一切似乎偏向于C#和我认为C#有更好的低层次的语言结构可用,可以帮助表现。不过,我怀疑这些差异真正的问题(他们甚至可能没有适用于您的情况下,使用指针获得你什么,如果你做的是数据库访问,Java所在可能会更快),如果选择妨碍你以其他方式(如去跨平台)。去正确性,符合你的要求,而不是小的性能差异的平台。

This all seems biased towards C# and I do think C# has better low level language constructs available that can help with performance. However, I doubt these differences really matter (and they might not even apply in your case, using pointers gains you nothing if all you do is database access, where Java might be faster) if the choice impedes you in some other way (like going cross platform). Go for correctness, the platform that matches your requirements, rather than minor performance differences.

这篇关于在Java虚拟机VS .NET CLR基准业绩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆