Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Telamon

C# is not Fast! Re: Today's Earlier Benchmark

This topic is 5307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So earlier today I posted a naive floating point benchmark showing that C++ and C# were equally fast. This was an invalid test for many reasons that were pointed out to me. As a follow-up, I have now almost completely rewritten (well, copied mostly) my C# procedural texture generator as a DLL written in C++. I have not even begun to optimize the C++ code (using cosine tables, inlining, caching values, ect...) and already it is performing 5-8 times faster that my C# version. I can generate a 1024x1024 perlin noise field with 5 octaves and cubic interpolation in 1 second. My previous code can take 10 seconds to do this. I anticipate that by the time I am done, it will actually be faster to generate a planet texture on the fly than it will be to load one from disk! So I was very wrong. Moving my intense calculations to C code really helped performance. Though I might point out that my original C# code was horribly inefficient and had a lot of headroom for optimization without changing languages. So it's unclear how much of the performance gain is due to me being much more experienced with writing fast code in C vs. C#. The ultimate winner is everybody, though. I'll be releasing my texture generation code soon, and because I went through the trouble of writing a DLL, you'll be able to plug it into just about anything. This is also not to say that C# is a poor language - I like it a lot. Different tools for different jobs... ---------------------------------------- Let be be finale of seem, seems to me. ---------------------------------------- Shedletsky's Code Library: Open source projects and demos [edited by - Telamon on April 15, 2004 12:48:56 AM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
So it''s unclear how much of the performance gain is due to me being much more experienced with writing fast code in C vs. C#.

And yet you post an almost intentionally inflammatory subject line and speak as if you do know what you are talking about.

Share this post


Link to post
Share on other sites
Was the old thread deleted? Great!

Although your benchmark test shows a complete different result, the postings concerning benchmark tests and other things were true.

C# is fast, however the startup time (first execution of code parts is much slower due to jit compilation). I hope you had that in mind when you did your "benchmark" test.


Have fun
Bunnz
Purple#, a shader-driven game engine for .NET.

Share this post


Link to post
Share on other sites
Yeah, I deleted the other thread when it became obvious it had no value.

Both the C# code and the C++ DLL will be slow the first time it is run, since one needs to be JITed and the other needs to be dynamically linked.

antareus: In fact, I do know what I am talking about. My point was that the huge speedup I acheived should not be viewed as concluding "C# is really slow". I''m sure an experienced .Net programmer could optimize my C# code and make it run twice as fast. But there''s more overhead in C#, so I doubt it''s possible to make the C# code run 5 - 8 faster.

The subject line makes it clear that this is a follow-up post. It is not meant to be inflammatory but rather ironic. I won''t apologize if you missed that.

----------------------------------------
Let be be finale of seem, seems to me.
----------------------------------------

Shedletsky''s Code Library:

Open source projects and demos

Share this post


Link to post
Share on other sites
quote:
the C# code and the C++ DLL will be slow the first time it is run, since one needs to be JITed and the other needs to be dynamically linked.



very clever


Have fun
Bunnz
Purple#, a shader-driven game engine for .NET.

Share this post


Link to post
Share on other sites
quote:
Original post by Telamon
Yeah, I deleted the other thread when it became obvious it had no value.
This one can now follow suit, as you have no clue how to benchmark.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I vote this for the "Most stupid thread of the year award" who''s with me

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Wrong forum! Here is a link to your forum: http://www.gamedev.net/community/forums/forum.asp?forum_id=31

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
This one can now follow suit, as you have no clue how to benchmark.


I used to think you were a competent mod... Oh well, next time, think before you post.

Share this post


Link to post
Share on other sites

This topic is 5307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!