Hi,
It ran VERY quickly on alpha:
DILLONA@alpha$ run fib
Fibonacci Benchmark
The 40'th Fibonacci Number is: 102334155
Run Time (sec) = 7.700
DILLONA@alpha$
MikeR,
fib.c:
- Code: Select all
#define VMS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
void main(void);
unsigned long fib(long);
unsigned long fib(x)
long x;
{
if (x > 2)
return(fib(x-1)+fib(x-2));
else
return(1);
}
void main()
{
register unsigned long IMax,value;
double starttime, benchtime, dtime();
IMax = 40;
printf("\n");
printf("Fibonacci Benchmark\n");
starttime = dtime();
value = fib(IMax);
benchtime = dtime() - starttime;
printf("\n");
printf("The %02d'th Fibonacci Number is: %d\n",IMax,value);
printf("Run Time (sec) = %10.3lf\n\n",benchtime);
}
/*********************************************************/
/* VMS dtime() for VMS systems. */
/* Provided by: RAMO@uvphys.phys.UVic.CA */
/* Some people have run into problems with this timer. */
/*********************************************************/
#ifdef VMS
#include time
#ifndef HZ
#define HZ 100
#endif
struct tbuffer_t
{
int proc_user_time;
int proc_system_time;
int child_user_time;
int child_system_time;
};
struct tbuffer_t tms;
double dtime()
{
double q;
times(&tms);
q = (double)(tms.proc_user_time) / (double)HZ;
return q;
}
#endif
Sorry to put that in a post, but other people may want it as well.
If anyone wants the full source (meaning UNIX, windows, DOS, etc.) PM me.
Zoli,
I will run it on the new AIX box as soon as it is online. As for the other box, IMHO both shouldn't be online.
There are 10 types of people in this world, those who understand binary and those who don't.