西西河

主题:【倡议】Java SE 5.0和.NET 2.0擂台赛 -- Highway

共:💬34
全看分页树展 · 主题 跟帖
家园 一个二者性能比较的例子

这是我从网上找来的,本来应该以文摘的方式转载,但是西西河的文章标题长度限制使得它成为不可能,我只好把它附在内容里了。

.NET 2.0 and Java 1.5 for numerical computing

Going ahead with my numerical algorithms translation, I started to wonder if I was going to win something in performance. Is .NET 2.0 going to be faster than Java 1.5 for numerical computing? To find out, I downloaded the SciMark2 benchmark from the http://math.nist.gov site and I translated it to C# using Visual C# Express, at this point I didn't try to understand (let alone enhance) the code, only to get it working in C# (except a couple of obvious changes like using Array.CopyTo() to copy arrays). Anyway, these are the results I got with Java 1.5 Beta 2 in my portable (2.8 GHz Mobile Intel Pentium 4 CPU):

Composite Score: 207.78646505369562

FFT (1024): 112.99822846954115

SOR (100x100): 378.42792716276983

Monte Carlo : 47.71337303709922

Sparse matmult (N=1000, nz=5000): 144.6072353535397

LU (100x100): 355.1855612455282

And these are the results I got with .NET 2.0 Beta 1:

Composite Score: 320.261977294581

FFT (1024): 225.063751509717

SOR (100x100): 395.271584950618

Monte Carlo : 18.592932017316

Sparse matmult (N=1000, nz=5000): 484.889267269725

LU (100x100): 477.492350725527

The results are in Mflops so Whidbey seems to be roughly 50% better than Tiger. Of course, these results are very preliminary and they will vary from machine to machine, so you can download the C# SciMark2 from http://www.logicstudio.net/Net2005/SciMark2.zip (the translation is awful right now and barely use C# idioms but, hey, it runs!) Give it a try and let me know how it goes.

Doing benchmarks is always dangerous, and doing it with betas even more so, so I run the benchmarks with Java 1.4.2_05 and got this:

Composite Score: 212.73680429939608

FFT (1024): 107.32467730480086

SOR (100x100): 376.06459421216255

Monte Carlo : 46.94569063386169

Sparse matmult (N=1000, nz=5000): 146.67860553090557

LU (100x100): 386.6704538152499

And with .NET 1.1.4322:

Composite Score: 336,152586167483

FFT (1024): 236,507205423729

SOR (100x100): 405,674738526316

Monte Carlo : 25,873449174941

Sparse matmult (N=1000, nz=5000): 476,624132235073

LU (100x100): 536,083405477354

For both platforms the production versions are better than the betas but note I run the tests in the same machine but with *different* Windows XP installations so don't jump into conclusions. In any case the difference between Java and .NET seems to be consistent.

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河