473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

speed of c# code in general compared to compiled native code

hi,

im wondering if there is a definitve answer to this.

If you build a winforms/wpf application in vs2008, when you have
compiled and run the app, does it run as fast (in general) as if you
used something like a xenocode compiler to convert to native code.

I hear things like the xenocode option only makes a minor speed
improvement in startup.

So what if you wanted to write a game in c# using the directx sdk.
Would you be better of using c++.

How can one know if there is a performance impediment in the whole
dotnet bytecode to native realtime conversion

thanks for any info

Peted
Jun 27 '08 #1
4 1868
On Thu, 12 Jun 2008 18:52:46 -0700, <Petedwrote:
im wondering if there is a definitve answer to this.
It's impossible for there to be one, as each program has different
performance requirements and characteristics.
If you build a winforms/wpf application in vs2008, when you have
compiled and run the app, does it run as fast (in general) as if you
used something like a xenocode compiler to convert to native code.
"In general", I have found little to no difference in execution speed.
Where there does happen to be a speed difference, it is almost always
related to my use of .NET, not the compiled C# code itself.
I hear things like the xenocode option only makes a minor speed
improvement in startup.
A quick look at the Xenocode web site suggests that it's doing a lot more
than just precompiling the application. But yes, inasmuch as it avoids
the JIT compiler having to compile the IL of your application, I can see
how startup would be faster. I don't think you'd use Xenocode for just
that reason though. It looks like a pretty heavy-weight approach.
So what if you wanted to write a game in c# using the directx sdk.
Would you be better of using c++.
I doubt it. At best, you might write your game physics and AI in C++, but
frankly I think any speed improvement, if any, would be negligible.
How can one know if there is a performance impediment in the whole
dotnet bytecode to native realtime conversion
Write both and compare it. Some algorithms will see a difference, some
will not. It's very difficult to know in advance which are which.

Pete
Jun 27 '08 #2

"Peted" wrote in message news:uv********************************@4ax.com...
hi,

im wondering if there is a definitve answer to this.
I am tracking with Peter on this one, as there are some cases where C++
smokes C# and a few where C# smokes C++. In general, both are fairly
equivalent. And, in those cases where you need something native, you can
always write in C++ for the algorithms that need that tweak.
If you build a winforms/wpf application in vs2008, when you have
compiled and run the app, does it run as fast (in general) as if you
used something like a xenocode compiler to convert to native code.
I would say yes, as there is generally not a lot of difference in speed of
UI, business logic and data access. When you move to serious graphical
calculations, as you suggest later, you might see a difference. I am not
sure I would use Xenocode to do this; it would probably be better to bite
the bullet and do it all in C++.
I hear things like the xenocode option only makes a minor speed
improvement in startup.
Not sure, but the startup time is definitely less if you do not have to JIT.
So what if you wanted to write a game in c# using the directx sdk.
Would you be better of using c++.
I would disagree a bit with Peter on this, as it would probably depend on
the game. Overall, since the majority of your graphics code is in the
DirectX libraries, there should not be a lot of difference, but you might
end up with a difference with certain types of game physics.
How can one know if there is a performance impediment in the whole
dotnet bytecode to native realtime conversion
I have found none, but I have not written a lot of gaming code. There are a
few cycles each time you marshall from managed to unmanaged, but this would
not be a major impediment unless you were constantly marshalling, as in a
very large loop. It would be easy enough to set up a simple application that
hits some DirectX bits and profile it both in native and managed. I believe
you will find that the calls add a few microseconds to the time, which is
neglegible in most cases.

That being said, I not sure I would write a game like Quake 4 in C#. ;-)

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************

Jun 27 '08 #3
Peted wrote:
If you build a winforms/wpf application in vs2008, when you have
compiled and run the app, does it run as fast (in general) as if you
used something like a xenocode compiler to convert to native code.
Generally there is little difference. A tool like xenocode might do some
tricks to speed up the code, but on the other hand the JIT can
potentially produce code that is optimised for the specific processor it
is running on. Also, the JIT is getting better and better, so your .NET
code will get faster with each new version of the framework.
I hear things like the xenocode option only makes a minor speed
improvement in startup.
The shorter startup time is the most noticable difference. Other
differences are much more subtle, and may also vary from one system to
another.

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #4
>So what if you wanted to write a game in c# using the directx sdk.
>Would you be better of using c++.

I doubt it. At best, you might write your game physics and AI in
C++, but frankly I think any speed improvement, if any, would be
negligible.
That's exactly what I wouldn't expect to help. The JIT is pretty decent at
optimizing loops and calculations. It's calls to external libraries (like
DirectX, which definitely is a native component) where you get hurt,
especially if you forget to turn off security checks.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Maboroshi | last post by:
Hi I am fairly new to programming but not as such that I am a total beginner From what I understand C and C++ are faster languages than Python. Is this because of Pythons ability to operate on...
18
by: HerrLucifer | last post by:
I am each day becoming more and more addicted to the new .Net framework because of its cool RAD facilities. However, performance and speed is extremely important for my application development. I...
3
by: main\(\){}; | last post by:
I can't ignore the speed of .NET managed applications in manipulating string, I/O and arithmetic operations. However, we can never compare the speed of a C/C++ program with its .NET counterpart...
30
by: Mike Cox | last post by:
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program...
20
by: Tim Mulholland | last post by:
This thread is intended to be more of a discussion thread - because i value the opinions of the posters in this newsgroup, and especially the MVPs like Nicholas Paladino and Jon Skeet (thanks to...
4
by: Joanna Carter \(TeamB\) | last post by:
Hi gurus. Does anyone have any experience as to whether .NET 2.0 will be any faster executing than .NET 1.1 ? We are looking at starting a new project in .NET and are getting feedback from...
3
by: Chris288 | last post by:
Hi, I have a problem where our app when compiled in VS2005 runs about 50% the speed it attains in VS2003. This is an unmanaged C++ app. I have tried most combinations of the optimization and...
6
by: Paul.Lee.1971 | last post by:
Hi, I'm designing an application that will allow users to interrogate a Mysql database, using some form of regex. The database will be fairly big, and I'm wondering whether using pre-compiled C++...
7
by: Peted | last post by:
Hi, im hoping someone cane provide or point to a definitive accurate explantion of dotnet compilation when run and the best way to optimise peformace when dotnet code is run first time and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.