Różne programy na zajęcia laboratoryjne z AK2
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

fibb_inline.c 597B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdio.h>
  2. // Jan Potocki 2020
  3. unsigned long fibb(unsigned long n);
  4. unsigned long long timestamp()
  5. {
  6. unsigned long long tsc;
  7. asm volatile(
  8. "xor %%eax, %%eax\n"
  9. "cpuid\n"
  10. "rdtsc"
  11. : "=A" (tsc)
  12. :
  13. : "ebx", "ecx"
  14. );
  15. return tsc;
  16. }
  17. int main()
  18. {
  19. unsigned long term, result;
  20. unsigned long long tstamp1, tstamp2;
  21. scanf("%lu", &term);
  22. tstamp1 = timestamp();
  23. result = fibb(term);
  24. tstamp2 = timestamp();
  25. printf("Result: %lu\n", result);
  26. printf("Cycles: %llu\n", tstamp2-tstamp1);
  27. return 0;
  28. }