|
From: jgana <jg...@vt...> - 2002-08-19 17:16:54
|
First, thanks to everybody for your help
Second, forgive me, if I am asking something stupid=85You know, I am
learning.
I found out that a console program that is compiled with Dev-C++ (Mingw)
can run perfectly well in Linux and a lot faster. The program runs ~70%
slower in Windows.=20
Why there is a difference in speed if I am using the same machine?
(Pentium 400 MHz)=20
The program that I used is a very inefficient way to calculate the
Fibonacci Series. But, the point was to have a rough idea of the speed.
The Dev-C++ (Mingw) executable in windows took 1 minute 45 seconds in
finding the 22th element of the Fibonacci Series (17,711). The same
executable in Linux took 30 seconds to find the 22th element.
=20
#include <iostream.h>
#include <stdlib.h>
int Fib(int n);
int main()
{
using namespace std;
int n, answer, stop;
=20
cout <<"Enter number to find: ";
cin >>n;
cout <<"\n\n";
answer=3DFib(n);
cout << answer <<" is the " << n <<"th Fibonacci number\n";
=20
cin >>stop;
return 0;
}
int Fib(int n)
{
cout <<"Processing Fib(" << n << ")...";
if (n<3)
{
cout <<"return 1!\n";
return (1);
}
else
{
cout <<"call Fib(" << n-2 <<") and Fib(" << n-1 << ").\n";
return( Fib(n-2)+Fib(n-1));
}
}
Best regards,
Jos=E9 Fco. Gana
Santiago, Chile.
|