All pastes #967072 Raw Edit

Someone

public text v1 · immutable
·published 2008-04-02 05:04 UTC
rendered paste body
our_clock.h:
------------
void our_clock(long long *b);

our_clock.s:
------------
.globl our_clock
.globl _our_clock
our_clock:
_our_clock:
rdtsc
movl 4(%esp),%ecx
movl %eax,(%ecx)
movl %edx,4(%ecx)
ret

main.c:
------------
#include <our_clock.h>
#include <stdio.h>

long long rdtsctime=0;

void init_clock() {
    long long a, b;
    our_clock(&a);
    our_clock(&b);
    rdtsctime=b-a;
}

int main() {
   long long t1,t2;
   init_clock(); /* Calibrate */
   our_clock(&t1);
   /* Insert code here */
   our_clock(&t2);
   printf("%lu\n",t2-t1-rdtsctime);
   return 0;
}