Date: Fri, 16 Oct 1998 12:48:29 +0100 (MET) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: Etienne.Debruin@KryptoKom.DE (Etienne de Bruin) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: timing a device driver Message-ID: <199810161148.MAA00773@labinfo.iet.unipi.it> In-Reply-To: <199810161022.MAA00614@borg.kryptokom.de> from "Etienne de Bruin" at Oct 16, 98 12:22:04 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810161148.MAA00773>