R2023.05.1 - aktualizacja wykładu
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user