Performance comparison C++, C# and Java
2004-11-21 19:27
501 查看
Performance comparison C++, C# and Java |
source: http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html Test System AMD Athlon XP 2200+ 1024 MB DDR 266 VIA KT266A Windows XP Prof. + SP1 Java Version + Options Java 1.4.2_03 Java 1.5 (alpha, 11. Dec. 03) compiler options: -g:none running options: -mx1024m C# Version + Options .Net Framework 1.1.4322 (Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4) compiler options: /optimize+ /debug- /checked- running options: C++ Version + Options Microsoft Visual Studio Net 2003 (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86) compiler options: /O2 /Oi /Og /Ot /EHsc /arch:SSE Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build 20031017Z compiler options: /fast /G6 /Oi /Og /Ot /EHsc /arch:SSE running options: Source Code Original Source Code is from Christopher W. Cowell-Shah http://www.cowell-shah.com/research/benchmark/code and from http://dada.perl.it/shootout/ and Doug Bagley http://www.bagley.org/~doug/shootout . I took portions and whole parts from both and put them into a single file and did some changes + bugfixes. Java C# C++ Results Maximum memory usage: Java - 163 MB C# - 111 MB Cpp - 98 MB Performance in ms: Cpp is the fastest, except the STL "hashmaps" test is a lot slower, maybe someone can take a look at the source code, I use STL <map>, because <hash_map> was slower.... The memory footprint of Cpp is also the lowest, which was expected. C# is quit fast (I would have been surprised, if C# were much slower than Java), but seems to have some problems with exception handling, matrix multiply and nested loops. Java's hash maps are very fast and the exception handling is also very strong. If you sum it up, Java gets 5 wins against C#, C# gets 9 wins against Java and Cpp gets 11 wins against C#. This black and white comparison only takes performance into account, but other values like development speed and security are also very important issues today. In my opinion it goes much faster to develop complex apps with Java or C#, than with plain Cpp and the STL. Type safety and buffer overrun issues are also much weaker in Cpp, so you have to do more work, which takes more time and will cost some speed! So every language has its strong areas, but as always, nothing comes for free... Update 15.04.04 Java Version + Options Java 1.5 (alpha, 11. Dec. 03) compiler options: -g:none running options: -mx1024m -Xbatch and -server for the server VM C# Version + Options .Net Framework 1.1.4322 (Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4) compiler options: /optimize+ /debug- /checked- running options: C++ Version + Options Microsoft Visual Studio Net 2003 (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86) compiler options: /Op /Oy /O2 /Oi /Og /Ot /EHsc /arch:SSE Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build 20031017Z compiler options: /Op /Oy /Qpc80 /fast /G6 /Oi /Og /Ot /EHsc /arch:SSE running options: Source Code Changes C++ :SLT VECTOR was replaced with the STL LIST, that's why the benchmark is now called "List". STDIO(C) was replaced with FSTREAM(C++). Java :STRINGBUFFER was replaced with STRINGBUILDER, timeing routines changes, "new Integer()" was replaced with Integer.valueOf(), VECTOR was replaced with LINKEDLIST, so all "List" benchmarks use now a list, only C# uses its ARRAYLIST, because there is no list or linked list in C# and thats the reason, why these benchmark is marked red! Java C++ Results Maximum memory usage: Java - 163 MB C# - 111 MB Cpp - 98 MB Performance in ms: Cpp is a little bit slower with more accurate floating point calculations and omitted frame pointers. The Java server VM is faster than the client VM, which was new to me, because I don't have that much Java experience. Trig. functions and maybe the memory footprint are the only weak points in Java today. The "hashmaps" benchmark uses a helper class in Java, to achive this high performance. If you don't use it, you will get 11000ms instead of 3640ms, but this optimisation isn't possible and necessary for the C++ and C# versions! Update 17.04.04 Java Version + Options Java 1.4.2_03 compiler options: -g:none running options: -mx1024m -Xbatch and -server for the server VM Excelsior JET 3.5 Results Maximum memory usage: Java - 163 MB C# - 111 MB Cpp - 98 MB Performance in ms: The server VM (1.4.2_03) is faster than the 1.5(alpha) server VM from above and it's always faster than its client version. The JET 3.5 code is faster than the client VM, but sometimes it is slower than the server VM. Trig. functions are as fast as the Cpp and the C# code, but they seems to use some lower precision for the sin, cos and tan functions. |
相关文章推荐
- Java vs C++ "Shootout" Revisited
- Performance of Java versus C++
- 基于Visual C++.NET的GDI+开发教程
- C/C++试题(from 周星星's Blog)
- VC学习资料收集(4):设计XP风格的按钮
- VC学习资料收集(3):谈新手对CString的使用
- 唐诗、OO、范式、C++
- C++ Primer学习笔记之第12章-泛型-踩在巨人的脚背上-prog12.cpp程序
- 利用C++Builder自定义Windows窗体“系统菜单”
- 自己学习C语言的一点心得
- VC实例学习 (1):总结下今天学习的东西
- 由C++转向C#:我们需要注意哪些方面的变化?
- 周星星C++之合集
- 关于C++复杂性的零碎思考(myan)
- 我的面向对象程序观
- Java的执行效率完全可以比C/C++的好
- C++ 代码覆盖率工具Bullseye Coverage(收藏)
- C++ Primer学习笔记第九章-你真的知道何时用重载吗?
- FAQ
- C++学习经典