.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A performance question

2 REPLIES 2
Reply
Message 1 of 3
dmarcotte4
243 Views, 2 Replies

A performance question

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);
}
2 REPLIES 2
Message 2 of 3
Anonymous
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);
> }
Message 3 of 3
dmarcotte4
in reply to: dmarcotte4

Hey Adam,
That was it, they were compiled in debug mode. Thanks a ton.

Daniel

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost