Speed and C#

Started by
11 comments, last by GameDev.net 18 years, 7 months ago
Anybody got a chart or something depicting the difference in speed between c++ and c#?
------------------------Why of course the people don’t want war. ... That is understood. But after all it is the leaders of the country who determine the policy, and it is always a simple matter to drag the people along, whether it is a democracy, or a fascist dictatorship, or a parliament, or a communist dictatorship ...Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is to tell them they are being attacked, and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country. [Herman Goering]
Advertisement
The consensus is that C++ MIGHT be a BIT faster (1 to 2 percent) on certain occasions. The second consensus is that it REALLY doesn't matter.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
Quote:Original post by xMcBaiNx
The consensus is that C++ MIGHT be a BIT faster (1 to 2 percent) on certain occasions. The second consensus is that it REALLY doesn't matter.


I've seen people say the, and I too say the same thing, but noone ever showed real "charts" or proof of how this is true.

I recently googled for some speed comparision and found a site that said they compared C++, C, Java and C# speed-wise. In the end results, they claimed that C# ran even slower than Java. However, as I have experience with all aforementioned languages I declared those results bullshit.

C# definetly runs faster than Java, much faster, however, I have never seen any real proof of how much slower C# is compared to C++. And just because you read it on the internets, doesn't mean it's true. ;)

I'm a pro-C# programmer, and I use C# for games, but some real proof would be nice tho.

Toolmaker

What actually happens with the just-in-time-compilation that the c#-code goes trough?

Is the entire code compiled to machinecode only once at the beginning - as compared to java which lets the virtual machine compile the code over and over again at runtime?

Wouldnt that mean that the only overhead would really be the initial loadingtime (as the code is compiled), but subsequently the speed would be virtually the same as C++ (not considering other factors)?
------------------------Why of course the people don’t want war. ... That is understood. But after all it is the leaders of the country who determine the policy, and it is always a simple matter to drag the people along, whether it is a democracy, or a fascist dictatorship, or a parliament, or a communist dictatorship ...Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is to tell them they are being attacked, and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country. [Herman Goering]
Quote:Original post by _Danneman_
as compared to java which lets the virtual machine compile the code over and over again at runtime?


Java code is compiled [once] into bytecode (the .class files), which is then executed by the VM.
check out: http://shootout.alioth.debian.org/benchmark.php?test=all〈=csharp&lang2=gpp&sort=fullcpu
Programming Language Shootout compares language implementations with Debian packages for them.

Commercial stuff is missing this way, but you can download the testsuit and run it on the implementations you want to compare.

Even the opensource C# for Linux (Mono) is faster than Java, so it will certainly be faster on windows.

Mono vs Intel C++ Graph
You cant really compare languages like that, it depends on how you code. You could make a game in VB which are 1000% faster than the equivaliant C++ game, but that would be because the C++ code is worse than the VB code.

The JIT(Just-In-Time) compilation thing means that when you build your executable it wont get (completly) compiled. So the first time it reach some code it will be compiled, this means that your first run might be a little slow, but after that it is compiled (also next time you start your program).

Even though you cant directly compare C++ and C# speed, normally if two equally good programs are coded in both languages the C++ one tend to be a bit (couple of %s) faster.
In terms of game performance, even a discrepency of 10% is unlikely to take your game from playable to unplayable. Whether it's 110fps to 100fps or 33fps to 30fps, the difference is unnoticable to the end user. As a game developer you should be concerned with what gets the job done best- not what gets the job done eventually with a few more measly frames per second.

Quote:
C# definetly runs faster than Java, much faster

Sorry, but not even C++ runs much faster than Java on today's computers. If you want to talk about "problems" with Java, look at the memory consumption. Of course, that's a discussion for another day...
Quote:Original post by Anonymous Poster
Quote:
C# definetly runs faster than Java, much faster

Sorry, but not even C++ runs much faster than Java on today's computers. If you want to talk about "problems" with Java, look at the memory consumption. Of course, that's a discussion for another day...


Are you sure you know what you are talking about? C++ gets compiled to a binary format while Java, as far as I know, is saved as byte-code.

This topic is closed to new replies.

Advertisement