.NET

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

A performance question

77 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 (77 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 (77 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community