// #define PIT
#ifndef PIT
#include <time.h>
#endif
#include <stdio.h>
#include <conio.h>
#ifdef PIT
long biostime(void)
{
__asm mov ah,0
__asm int 0x1A
__asm mov ax,cx
__asm shl eax,16
__asm xor ecx,ecx
__asm mov ecx,edx
__asm add eax,ecx
}
#endif
long __fastcall fibonacci(int i)
{
if (i > 0) return (fibonacci(i-1)+fibonacci(i-2));
else return 1l;
}
void main(void)
{
long start_time,elapsed;
printf("Fibonacci benchmark, 32-bit version, (C) Marcin
Borkowski 1998\r\n");
#ifdef PIT
start_time = biostime();
#else
start_time = clock();
#endif
fibonacci(40);
#ifdef PIT
elapsed = biostime()-start_time;
#else
elapsed = clock() - start_time;
elapsed = 1907l*elapsed/CLOCKS_PER_SEC;
elapsed = 627l*elapsed/65536l;
#endif
printf("Elapsed time: %li clock ticks (%li FiboMHertz)\r\n",elapsed,128616/elapsed);
printf("Press any key to continue...\r\n");
while (!kbhit());
}