評測報告:.NET的效能仍然遠遠落後於Java (轉)
評測報告:的仍然遠遠落後於:namespace prefix = o ns = "urn:schemas--com::office" />
每個人都看過各種不同的benchmark,有證明.NET比Java快的,也有證明Java比.NET快的。在某些人的手裡,benchmark是一面魔鏡,透過它能看到想看的東西。所以,當這位名為Cameron的先生要開始在.NET和Java之間做一個benchmark時,他認為自己就是在浪費時間,因為肯定會有人來證明.NET比Java快。
順便地,Cameron先生提出了10條“不要用於在.NET和Java之間做選擇”的理由,其中包括:
Ø 在某一組特定的benchmark中,某一個比另一個快一點;
Ø Microsoft或Sun(或者、IBM……)的報告說其中一個比另一個好得多;
Ø 你喜歡(或不喜歡)Bill Gates或者tt McNeally(或者Larry Ellison);
Ø 你認為Microsoft或者Sun(或者IBM或者Oracle)很邪惡(或者很偉大);
Ø 你在TheServerS.com或者Got.com(或者Microsoft.com)讀了一篇“沒有偏見”的文章;
實際上,這次benchmark源於Cameron與tRolf兩人在TheServerSide.com網站的一次關於服務效能的爭吵(?thread_id=19226">)。在這次的benchmark中,Cameron測試了下列版本:
.NET 1.0sp2:
Microsoft (R) Visual Compiler version 7.00.9466
for Microsoft (R) .NET version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
.NET 1.1:
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
Sun Hotspot Server JVM from 1.3.1_04:
java version "1.3.1_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_04-b02)
Java HotSpot(TM) Server VM (build 1.3.1_04-b02, mixed mode)
Sun Hotspot Server JVM from JDK 1.4.0_02:
java version "1.4.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_02-b02)
Java HotSpot(TM) Server VM (build 1.4.0_02-b02, mixed mode)
Sun Hotspot Server JVM from JDK 1.4.1_02:
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
在程式碼方面,Cameron主要選擇了大量ArrayList來進行測試。下列是他的測試程式碼:
C#
// C# Create 100,000 people in an ArrayList and access them
using System;
using System.Collections;
public class ManyPeople
{
public static void Main()
{
for (int i = 0; i < 100; i++)
test(i);
}
public static void test(int iIter)
{
DateTime start = DateTime.Now;
for (int i = 0; i < 20; i++)
new ManyPeople().Average();
DateTime finish = DateTime.Now;
Console.WriteLine("Total time for iteration " + iIter + ": " + (finish - start));
}
private long Average()
{
ArrayList list = new ArrayList(100000);
for (int i = 0; i < 100000; i++)
list.Add(new Person(i, "John " + i));
long silly = 0;
foreach (Person p in list)
silly += p.Id;
return silly / 100000;
}
}
// Person.cs: a very simple guy
public class Person
{
int id;
string name;
public Person(int anId, string aName)
{
this.id = anId;
this.name = aName;
}
public int Id
{
get { return this.id; }
}
}
Java:
// Java Create 100,000 people in an ArrayList and access them
import java.util.*;
public class ManyPeople
{
public static void main(String[] args)
{
for (int i = 0; i < 100; i++)
test(i);
}
public static void test(int iIter)
{
long start = System.currentTimeMillis();
for (int i = 0; i < 20; i++)
new ManyPeople().average();
long finish = System.currentTimeMillis();
System.out.println("Total time for iteration " + iIter + ": " + (finish - start));
}
private long average()
{
ArrayList list = new ArrayList(100000);
for (int i = 0; i < 100000; i++)
list.add(new Person(i, "John " + i));
long silly = 0;
for (int i = 0; i < 100000; i++)
silly += ((Person)list.get(i)).getId();
return silly;
}
}
// Person.java: a very simple guy
class Person
{
private int id;
private String name;
public Person(int anId, String aName)
{
this.id = anId;
this.name = aName;
}
public int getId()
{
return this.id;
}
}
Cameron所用的測試機器是P3 1GHz、1G的筆記本,操作是 2000 SP2。下列是在.NET上測試的結果(取最好的6次):
.NET 1.0sp2:
ManyPeople
Total time for iteration 0: 00:00:07.3004976
Total time for iteration 1: 00:00:07.0501376
Total time for iteration 2: 00:00:07.2504256
Total time for iteration 3: 00:00:07.7311168
Total time for iteration 4: 00:00:07.5007856
Total time for iteration 5: 00:00:07.5007856
.NET 1.1:
ManyPeople
Total time for iteration 0: 00:00:08.0916352
Total time for iteration 1: 00:00:08.5222544
Total time for iteration 2: 00:00:08.3520096
Total time for iteration 3: 00:00:08.6324128
Total time for iteration 4: 00:00:08.3419952
Total time for iteration 5: 00:00:08.1617360
可以看到,同樣的程式碼在.NET 1.1上比.NET 1.0 SP2上慢了大約15%。這是一個很奇怪的現象。並且,Cameron觀察到,.NET上同樣程式碼的執行速度並不隨執行次數的增加而提高,說明.NET CLR只是簡單地進行了JIT編譯。而在Hotspot Server上,不僅開始時的效能就有優勢,而且速度還會不斷提高:
Sun Hotspot Server JVM from JDK 1.4.1_02:
java -server -Xms128m -Xmx128m ManyPeople
Total time for iteration 0: 6370
Total time for iteration 1: 5788
Total time for iteration 2: 5868
Total time for iteration 3: 6029
Total time for iteration 4: 5748
Total time for iteration 5: 5738
Total time for iteration 6: 5729
Total time for iteration 7: 5948
Total time for iteration 8: 5688
Total time for iteration 9: 5679
Total time for iteration 10: 5658
Total time for iteration 11: 6028
Total time for iteration 12: 5699
Total time for iteration 13: 5708
Total time for iteration 14: 5678
Total time for iteration 15: 5969
Total time for iteration 16: 5628
Total time for iteration 17: 5538
Total time for iteration 18: 5608
Total time for iteration 19: 5498
Total time for iteration 20: 5768
Total time for iteration 21: 5518
Total time for iteration 22: 5307
Total time for iteration 23: 4247
Total time for iteration 24: 4696
Total time for iteration 25: 4617
Total time for iteration 26: 4777
Total time for iteration 27: 4286
Total time for iteration 28: 4677
Total time for iteration 29: 4626
Total time for iteration 30: 4697
Total time for iteration 31: 4286
Total time for iteration 32: 4697
Total time for iteration 33: 4617
Total time for iteration 34: 4696
Total time for iteration 35: 4307
Total time for iteration 36: 4686
Total time for iteration 37: 4807
Total time for iteration 38: 4517
Total time for iteration 39: 4306
Total time for iteration 40: 4657
Total time for iteration 41: 4807
Total time for iteration 42: 4596
Total time for iteration 43: 4206
Total time for iteration 44: 4777
Total time for iteration 45: 4717
Total time for iteration 46: 4607
Total time for iteration 47: 4196
Total time for iteration 48: 4796
Total time for iteration 49: 4707
Total time for iteration 50: 4777
Total time for iteration 51: 4196
Total time for iteration 52: 4627
Total time for iteration 53: 4687
Total time for iteration 54: 4806
Total time for iteration 55: 4186
Total time for iteration 56: 4627
Total time for iteration 57: 4697
Total time for iteration 58: 4807
Total time for iteration 59: 4166
Total time for iteration 60: 4616
Total time for iteration 61: 4697
Total time for iteration 62: 4717
Total time for iteration 63: 4346
Total time for iteration 64: 4717
Total time for iteration 65: 4617
Total time for iteration 66: 4626
Total time for iteration 67: 4367
Total time for iteration 68: 4706
Total time for iteration 69: 4617
Total time for iteration 70: 4617
Total time for iteration 71: 4366
Total time for iteration 72: 4687
Total time for iteration 73: 4616
Total time for iteration 74: 4196
Total time for iteration 75: 4787
Total time for iteration 76: 4687
Total time for iteration 77: 4807
Total time for iteration 78: 4436
Total time for iteration 79: 4387
Total time for iteration 80: 4676
Total time for iteration 81: 4807
Total time for iteration 82: 4417
Total time for iteration 83: 4296
Total time for iteration 84: 4686
Total time for iteration 85: 4797
Total time for iteration 86: 4266
Total time for iteration 87: 4697
Total time for iteration 88: 4617
Total time for iteration 89: 4717
Total time for iteration 90: 4276
Total time for iteration 91: 4707
Total time for iteration 92: 4616
Total time for iteration 93: 4697
Total time for iteration 94: 4296
Total time for iteration 95: 4677
Total time for iteration 96: 4546
Total time for iteration 97: 4697
Total time for iteration 98: 4296
Total time for iteration 99: 4677
可以看到,隨著執行次數的增加,Sun Hotspot Server不斷將領先優勢拉大,最後幾乎比.NET 1.1快了一倍。.NET CLR始終無法將執行時間降低到8秒以下,而Sun Hotspot Server在多次執行之後則可以保持在5秒以下。因此,Cameron認為,對於大運算量的應用,Hotspot JVM比Microsoft CLR要快得多。
原文及完整的benchmark資料請看Cameron的blog:
rdy/0516">
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-956727/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 遠遠落後大陸臺灣移動網際網路怎麼跑慢了?
- TheServerSide.com釋出最新J2EE vs. .NET效能評測報告 (轉)ServerIDE
- Computerworld:智慧電視安全防禦水平遠落後於手機和PC
- 為 java 開發者設計的效能測試框架,用於壓測+測試報告生成Java框架測試報告
- 知乎離“天涯淪落”有多遠?
- drbd的效能測試報告測試報告
- 遠端工作報告:從遠端到混合
- redis效能測試報告Redis測試報告
- 大眾點評:移動生活報告顯示Android使用者消費能力遠低於iPhoneAndroidiPhone
- 2021年12月雲主機效能評測報告
- 2021年11月雲主機效能評測報告
- 2021年9月雲主機效能評測報告
- 最新Windows份額統計:win10上升速度慢 遠落後於win7WindowsWin10Win7
- 軟體效能測試報告應該包含的內容,效能測試報告需要多少錢?測試報告
- 最權威的輻射評測報告
- 本機生成遠端資料庫AWR報告資料庫
- 關於類似於awr的效能分析報告
- 軟體驗收測評報告怎麼做?軟體測評報告費用標準
- CAMIA:越南企業在區塊鏈和AI應用方面仍然落後於國際水平區塊鏈AI
- 遠端telnet登入進linux(轉)Linux
- 效能測試報告編寫技巧測試報告
- Java遠端呼叫Java
- SSH Exporter:基於Prometheus的遠端系統效能監控神器ExportPrometheus
- 軟體效能測試報告怎麼編寫?哪些機構可以出具效能測試報告測試報告
- SafetyNet Attestation API:遠端評估Android裝置的真偽APIAndroid
- 在Java中實現遠端方法呼叫(轉)Java
- 軟體測評報告做為招標評分項
- Mono 3.2.3 TCP吞吐效能測試報告MonoTCP測試報告
- 軟體測評報告快問快答(二)
- ORACLE AWR效能報告和ASH效能報告的解讀Oracle
- 遠端控制篇:抓取遠端螢幕影像 (轉)
- iOS APNS推送遠端訊息 java後臺實現iOSJava
- 商業軟體聯盟:2013年全球雲端計算評測研究報告 金磚四國仍落後已開發國家
- asp.net下檢測遠端URL是否存在的三種方法ASP.NET
- 這4款最好用的遠端桌面訪問軟體,親測好評
- 遠端維護電腦裝置,最好用的三款軟體評測
- LLM仍然不能規劃,刷屏的OpenAI o1遠未達到飽和OpenAI
- 【最新】Chrome遠端程式碼執行0day分析報告Chrome