Re: [linux-audio-dev] best method for timing

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] best method for timing
From: xk (xk_AT_myrealbox.com)
Date: Tue Apr 16 2002 - 20:08:48 EEST


In Windows I use the rdtsc assembler instruction. It returns a 64 bit
integer (in EAX:EDX I think) which represent the amount of processors cycles
that have passed from the last reset. Computing the difference between two
values and taking into account the freq of the CPU (you have to figure it
out somehow), you get a very accurate timer.

Maybe someone can convert this code to Linux:

static __int64 __declspec(naked) rdtsc()
{
  __asm
 {
    rdtsc
    ret
  }
}

You use it like this:

///////////////////////////////////
__int64 A, B;

A = rdtsc();
// do something
B = rdtsc();

printf("CPU cycles spent: %d\n", (int) (B - A));
///////////////////////////////////


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Wed Apr 17 2002 - 00:18:53 EEST