39 lines
597 B
C
39 lines
597 B
C
#include <stdio.h>
|
|
|
|
// Jan Potocki 2020
|
|
|
|
unsigned long fibb(unsigned long n);
|
|
|
|
unsigned long long timestamp()
|
|
{
|
|
unsigned long long tsc;
|
|
|
|
asm volatile(
|
|
"xor %%eax, %%eax\n"
|
|
"cpuid\n"
|
|
"rdtsc"
|
|
: "=A" (tsc)
|
|
:
|
|
: "ebx", "ecx"
|
|
);
|
|
|
|
return tsc;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
unsigned long term, result;
|
|
unsigned long long tstamp1, tstamp2;
|
|
|
|
scanf("%lu", &term);
|
|
|
|
tstamp1 = timestamp();
|
|
result = fibb(term);
|
|
tstamp2 = timestamp();
|
|
|
|
printf("Result: %lu\n", result);
|
|
printf("Cycles: %llu\n", tstamp2-tstamp1);
|
|
|
|
return 0;
|
|
}
|