RDTSC Implementation issue:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GloriousDaisy
    New Member
    • Sep 2008
    • 1

    RDTSC Implementation issue:

    I have to use rdtsc on ubuntu for performance evaluation. But i am not getting the correct value. I am placing a sleep og 10 seconds, but value i get is some 1 sec... i dont know where im going wrong?

    #include<sys/time.h>
    #include<time.h >
    #include<stdio. h>
    typedef unsigned long long ticks;

    static __inline__ ticks getticks(void)
    {
    unsigned a, d;
    asm("cpuid");
    asm volatile("rdtsc " : "=a" (a), "=d" (d));

    return (((ticks)a) | (((ticks)d) << 32));
    }
    int main(){
    int r = 0;
    ticks tick,tick1,tick h;
    unsigned time =0;

    tick = getticks();

    sleep(10);

    tick1 = getticks();

    time = (unsigned)((tic k1-tick)/1662543);
    printf("\ntime in MS%u\n",time);
    return 0;
    }

    cat /proc/cpuinfo gives
    pprocessor : 0
    vendor_id : GenuineIntel
    cpu family : 6
    model : 14
    model name : Genuine Intel(R) CPU T2300 @ 1.66GHz
    stepping : 8
    cpu MHz : 1662.543
    cache size : 2048 KB
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 10
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tm pbe constant_tsc up arch_perfmon bts pni monitor vmx est tm2 xtpr
    bogomips : 3328.87
    clflush size : 64
Working...