From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 21 11:43:32 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3D1A516A4CE for ; Fri, 21 Jan 2005 11:43:32 +0000 (GMT) Received: from smtpx.spintech.ro (smtpx.spintech.ro [81.181.24.231]) by mx1.FreeBSD.org (Postfix) with ESMTP id E213F43D3F for ; Fri, 21 Jan 2005 11:43:31 +0000 (GMT) (envelope-from aanton@spintech.ro) Received: from smtpx.spintech.ro (antivirus [15.0.0.1]) by smtpx.spintech.ro (Postfix) with ESMTP id 18DC03A540 for ; Fri, 21 Jan 2005 10:26:27 +0000 (UTC) Received: from [10.0.0.2] (beastie [10.0.0.2]) by smtpx.spintech.ro (Postfix) with ESMTP id DC39C3A50B for ; Fri, 21 Jan 2005 10:26:26 +0000 (UTC) Message-ID: <41F0EB25.5030404@spintech.ro> Date: Fri, 21 Jan 2005 13:44:37 +0200 From: Alin-Adrian Anton User-Agent: Mozilla Thunderbird 1.0 (X11/20041229) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <20050120004406.GF921@einstein.lab> <41EFBEA5.50007@spintech.ro> <84dead72050120181965c70231@mail.gmail.com> In-Reply-To: X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Open-Source: www.opensource.org Subject: Re: clock time in milliseconds into a c program X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2005 11:43:32 -0000 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..