mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
25 lines
378 B
C
25 lines
378 B
C
#include <stdio.h>
|
|
|
|
unsigned long read_cycles()
|
|
{
|
|
unsigned long cycles;
|
|
asm volatile ("rdcycle %0" : "=r" (cycles));
|
|
return cycles;
|
|
}
|
|
|
|
extern int job();
|
|
|
|
int main() {
|
|
unsigned long start, end;
|
|
int answer;
|
|
|
|
start = read_cycles();
|
|
answer = job();
|
|
end = read_cycles();
|
|
|
|
printf("cycles: %lu\n", end - start);
|
|
printf("answer: %d\n", answer);
|
|
|
|
return 0;
|
|
}
|