From owner-freebsd-hackers Fri Oct 16 06:47:29 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA28909 for freebsd-hackers-outgoing; Fri, 16 Oct 1998 06:47:29 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id GAA28895 for ; Fri, 16 Oct 1998 06:47:02 -0700 (PDT) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id MAA00773; Fri, 16 Oct 1998 12:48:30 +0100 From: Luigi Rizzo Message-Id: <199810161148.MAA00773@labinfo.iet.unipi.it> Subject: Re: timing a device driver To: Etienne.Debruin@KryptoKom.DE (Etienne de Bruin) Date: Fri, 16 Oct 1998 12:48:29 +0100 (MET) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <199810161022.MAA00614@borg.kryptokom.de> from "Etienne de Bruin" at Oct 16, 98 12:22:04 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > i would like to time my device driver from within the kernel. > so, what functions exist for me to be able to time, in miliseconds, > how long a chunk of code takes. a method that i find nice and cheap if you have a pentium is to use the CPU cycle counter, accessible as follows: u_long ticks_used, event_count; ... quad_t ticks; ticks = rdtsc(); ... interesting code ... ticks_used += (u_long)(rdtsc() - ticks) ; event_count++; i generally declare the two variables as SYSCTL variables SYSCTL_INT(_net_link_ether, OID_AUTO, bdgint, CTLFLAG_RW, &ticks_used,0,""); so you can read/set them using sysctl cheers luigi -----------------------------+-------------------------------------- Luigi Rizzo | Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it | Universita' di Pisa tel: +39-50-568533 | via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 | http://www.iet.unipi.it/~luigi/ _____________________________|______________________________________ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message