Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 2000 12:17:15 -0800 (PST)
From:      Richard Hodges <rh@matriplex.com>
To:        Hao Zhang <zhanghao@nortelnetworks.com>
Cc:        "'freebsd-hackers@FreeBSD.ORG'" <freebsd-hackers@FreeBSD.ORG>
Subject:   Re: high speed timestamp counter
Message-ID:  <Pine.BSF.4.10.10011021215230.9117-100000@mail.matriplex.com>
In-Reply-To: <E1A4B2CC91EBD1118A510000F80836F80254FD5B@zwdld002.ca.nortel.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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
  rh@matriplex.com  | Carson City, NV 89706
    775-886-6477    | www.matriplex.com 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.10011021215230.9117-100000>