high speed timestamp counter

2000-11-02 Thread Hao Zhang
Title: high speed timestamp counter





Hi there,


I am trying to read the on board Pentium Time Stamp Counter. Is there an API in Unix that allows me to read it directly?

Or some assembly language line that I can drop into my code?


I need the high speed counters to profile some code. I don't want to use the classical time API that is provided in time.h


-Hao





Re: high speed timestamp counter

2000-11-02 Thread Volker Stolz

Am 02. Nov 2000 um 19:00 MET schrieb Hao Zhang:
 I am trying to read the on board Pentium Time Stamp Counter. Is there an API
 in Unix that allows me to read it directly?

Try 'man 4 perfmon'. Remember it requires an option in the kernel, though.
-- 
Volker Stolz * [EMAIL PROTECTED] * PGP + S/MIME


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: high speed timestamp counter

2000-11-02 Thread Richard Hodges

On Thu, 2 Nov 2000, Hao Zhang wrote:

 Hi there,
 
 I am trying to read the on board Pentium Time Stamp Counter. Is there an API
 in Unix that allows me to read it directly?
 Or some assembly language line that I can drop into my code?
 
 I need the high speed counters to profile some code. I don't want to use the
 classical time API that is provided in time.h

#define GET_RDTSC(var) {__asm__ volatile("rdtsc":"=A"(var)); }

{
  long long   timeval1, timeval2, diff;

  GET_RDTSC(timeval1);

  do_something();

  GET_RDTSC(timeval2);

  diff = timeval2 - timeval1;
}

Is this what you had in mind?

All the best,

-Richard   

---
   Richard Hodges   | Matriplex, inc.
  title   | 769 Basque Way
  [EMAIL PROTECTED]  | Carson City, NV 89706
775-886-6477| www.matriplex.com 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message