C# vs. C++ performance [modified] (Contest)
-
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
-
Is it .NET2?? .NET2 is much better than .NET1 !
-
Good!
-
Alright, you won! ;)
-
AMD Sempron 2800+ 1.61 GHz No wonder you are twice as fast!
Super Lloyd wrote:
No wonder you are twice as fast!
grumble grumble growl... you made me pull out my 7.2 .net on the laptop, compile, move the application over and run... ;P 1000ms C# 562 Intel C++ Satisfied yet? yes, I moved to release on both, yes, using optimized on both rather than YOUR optimized on one and non on the other....
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
Super Lloyd wrote:
No wonder you are twice as fast!
grumble grumble growl... you made me pull out my 7.2 .net on the laptop, compile, move the application over and run... ;P 1000ms C# 562 Intel C++ Satisfied yet? yes, I moved to release on both, yes, using optimized on both rather than YOUR optimized on one and non on the other....
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
Hey, I did optimize both! didn't you see the -O3 ?! Well the result are... well.... I didn't know gcc was that bad!.... :omg: That make me rethink about life! :laugh:
-
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
Super Lloyd wrote:
I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
From the top of my head:
#include <iostream>
using namespace std;int main()
{
double sum = 0.;
for (unsigned i = 0; i < 0xffffffU; ++i) {
char buffer[1024];
for (int j = 0; j < 1024; ++j)
sum += buffer[j];
}
cout << sum;
}-- modified at 12:20 Tuesday 1st August, 2006
-
AMD Sempron 2800+ 1.61 GHz No wonder you are twice as fast!
Super Lloyd wrote:
AMD Sempron 2800+ 1.61 GHz No wonder you are twice as fast!
I just looked at your specs... you realize that the 2800+ is the relative performance compared to an Intel right? My AMD is only 1.8ghz and runs faster than this one at work. I don't have any of my fast computers at the moment. :)
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
I tried cl /O2 /EHsc sieve.cpp It compiled without any message but crashed right away... Now, if C++ is so much more powerfull, why do I need an optimized compiler? :doh:
Super Lloyd wrote:
Now, if C++ is so much more powerfull, why do I need an optimized compiler?
You obviously have no clue as to the difference between what a compiler is and what a language is.
Jeremy Falcon
-
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
-
Super Lloyd wrote:
Now, if C++ is so much more powerfull, why do I need an optimized compiler?
You obviously have no clue as to the difference between what a compiler is and what a language is.
Jeremy Falcon
if it is so obvious there is no need to add anything ;P although I could comment that I do have no clue about what is the diference between the gcc compiler and an optimized compiler ;P
-
I simply took the sources from the article: http://www.csharphelp.com/archives2/archive458.html[^]
-
Super Lloyd wrote:
Hey, GCC is not so bad!
Nope, it's only slower than C#, that is a great selling point! :laugh:
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
If I'm using MSVC, do you think it's really worth it to switch over to Intel's compiler? And, does it integrate into VS? Just curious to know, as I've never used it, but I've heard positive stories about it.
Jeremy Falcon
-
Super Lloyd wrote:
I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
From the top of my head:
#include <iostream>
using namespace std;int main()
{
double sum = 0.;
for (unsigned i = 0; i < 0xffffffU; ++i) {
char buffer[1024];
for (int j = 0; j < 1024; ++j)
sum += buffer[j];
}
cout << sum;
}-- modified at 12:20 Tuesday 1st August, 2006
Well, previous post have shown the speed superiority of C++ already. And the slowness of GCC as well. And it's time to go to bed for me so I won't test it now. But here is the C# version:
using System;
class Test
{
static void Main()
{
double sum;
// you can't use unintialized buffer in C#
// and I though a new at each iteration was overkill
char[] buf = new char[1024];
for(uint i=0; i -
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
Time to go to bed... But I wonder if someone could be so kind to redo the test with a 3rd compiler & language (actuially run the 3 test on its computer, so we could compare!) The C++ & C# version http://www.csharphelp.com/archives2/archive458.html[^] and the D version! The source is there: http://www.digitalmars.com/d/overview.html[^] At the end of the page. And the compiler could be downloaded from there[^].
-
if it is so obvious there is no need to add anything ;P although I could comment that I do have no clue about what is the diference between the gcc compiler and an optimized compiler ;P
Super Lloyd wrote:
if it is so obvious there is no need to add anything
It's obvious to us; it's apparently not obvious to you. :-D
Jeremy Falcon
-
Well, previous post have shown the speed superiority of C++ already. And the slowness of GCC as well. And it's time to go to bed for me so I won't test it now. But here is the C# version:
using System;
class Test
{
static void Main()
{
double sum;
// you can't use unintialized buffer in C#
// and I though a new at each iteration was overkill
char[] buf = new char[1024];
for(uint i=0; iSuper Lloyd wrote:
and I though a new at each iteration was overkill
Of course it is an overkill, but it is a benchmark, isn't it?
-
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
Uh, frankly, 95% of the time, I don't care. 95% of the time, the programmer writes such crappy code, performance is the least of my worries. Marc
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
People are just notoriously impossible. --DavidCrow
There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer -
Uh, frankly, 95% of the time, I don't care. 95% of the time, the programmer writes such crappy code, performance is the least of my worries. Marc
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
People are just notoriously impossible. --DavidCrow
There's NO excuse for not commenting your code. -- John Simmons / outlaw programmerMarc Clifton wrote:
Uh, frankly, 95% of the time, I don't care. 95% of the time, the programmer writes such crappy code, performance is the least of my worries.
Amen, brother Marc! :-D
:josh: My WPF Blog[^]
-
On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!
Interesting Article (when including the links!) by Raymond Chen Clickety[^] Executive Summary: C++ wins, if you pull all tricks and invest to much time.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree in C# || Fold With Us! || sighist