Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2005 13:44:37 +0200
From:      Alin-Adrian Anton <aanton@spintech.ro>
To:        freebsd-hackers@freebsd.org
Subject:   Re: clock time in milliseconds into a c program
Message-ID:  <41F0EB25.5030404@spintech.ro>
In-Reply-To: <c2d45d6e050121015876defa22@mail.gmail.com>
References:  <20050120004406.GF921@einstein.lab> <41EFBEA5.50007@spintech.ro> <84dead72050120181965c70231@mail.gmail.com> <c2d45d6e050121015876defa22@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Claudiu Dragalina-Paraipan wrote:
> Or you can use PERFMON. Check manual page for perfmon.
> It gives you access to internal counters of CPU.
> 
> Of course this is a subjective measurement, since, AFAIK, the counters
> are not kept separately for every process, but for entire system,
> including kernel.
> Maybe repeating the same measurement for many times, with a system
> running no other CPU consumers, you will get a more accurate
> measurement
> 

As I said, multiple measurements provide better accuracy. Much better.

And as Joseph Koshy pointed out, the RDTSC instruction (works on Pentium 
i think) may even provide better accuracy then just measuring time. 
Using it in a cycle of measurements would provide relevant output, and 
perhaps more accurate then PERFMON (because of direct CPU access).

clock_gettime also provides nanoseconds resolution, as pointed out.


-- 
Alin-Adrian Anton
GPG keyID 0x1E2FFF2E (2963 0C11 1AF1 96F6 0030 6EE9 D323 639D 1E2F FF2E)
gpg --keyserver pgp.mit.edu --recv-keys 1E2FFF2E

Never ask a man what OS he uses. If it's FreeBSD, he'll tell you.
If it's not, why embarrass him? ..I'm sorry..



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41F0EB25.5030404>