.NET

Reply
Distinguished Contributor
dmarcotte4
Posts: 195
Registered: ‎04-02-2005
Message 1 of 3 (79 Views)

A performance question

79 Views, 2 Replies
12-08-2005 09:33 PM
Don’t mean to waste news group space. But why is c# roughly 5 times faster than C++ running the same code. I certainly thought it would be the other way around.

//c# .net 2.0
int Fibonacci(int n)
{
if (n == 0 || n == 1)
return n;
else
return Fibonacci(n - 1) + Fibonacci(n - 2);
}


//c++ VC++7 standard
long Fibonacci(int n)
{
if (n == 0 || n == 1)
return n;
else
return Fibonacci(n - 1) + Fibonacci(n - 2);
}
*Adam Nagy
Message 2 of 3 (79 Views)

Re: A performance question

12-09-2005 05:19 AM in reply to: dmarcotte4
Hello Danielm,

Try out both in release mode...

Cheers,
Adam
> Don't mean to waste news group space. But why is c# roughly 5 times
> faster than C++ running the same code. I certainly thought it would
> be the
> other way around.
> //c# .net 2.0
> int Fibonacci(int n)
> {
> if (n == 0 || n == 1)
> return n;
> else
> return Fibonacci(n - 1) + Fibonacci(n - 2);
> }
> //c++ VC++7 standard
> long Fibonacci(int n)
> {
> if (n == 0 || n == 1)
> return n;
> else
> return Fibonacci(n - 1) + Fibonacci(n - 2);
> }
Distinguished Contributor
dmarcotte4
Posts: 195
Registered: ‎04-02-2005
Message 3 of 3 (79 Views)

Re: A performance question

12-09-2005 02:10 PM in reply to: dmarcotte4
Hey Adam,
That was it, they were compiled in debug mode. Thanks a ton.

Daniel
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.