.NET

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

A performance question

80 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 (80 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 (80 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.