Code:
#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) <<));
}
int main () {
int r = 0;
Ticks Tick,tick1,tickh;
Unsigned long long time =0;
Tick = Getticks ();
Sleep (a);
Tick1 = Getticks ();
Time = (unsigned) ((Tick1-tick)/1662543);
printf ("/ntime in MS%llu/n", time);
return 0;
}
Cat/proc/cpuinfo gives Code:
pprocessor:0 Vendor_id:genuineintel CPU Family:6 model name : Genuine Intel (R) CPU T2300 @ 1.66GHz stepping:8 CPU mhz:1662.543 Cache size:20 KB fdiv_bug:no hlt_bug:no f00f_bug:no coma_bug:no fpu:yes fpu_except Ion:yes cpuid level:10 wp:yes flags:fpu vme de PSE TSC MSR PAE MCE cx8 APIC Sep MTRR PGE MCA cm OV 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