Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Mar 2009 11:17:55 -0400
From:      Mari Kotlov <mkotlov@gmail.com>
To:        freebsd-performance@freebsd.org
Subject:   sysctl with KERN_BOOTTIME option vs. gettimeofday()
Message-ID:  <3edc36610903170817t7ab70c16tdeed1cb3a99e9a52@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi everyone,
I am doing a port of C++ code from Windows to FreeBSD and need to
replace function GetTickCount(), which is used mostly for the purposes
of obtaining elapsed time (e.g. as a millisecond timer). As I
understand it, there are two ways to do that: 1) via sysctl() function
with CTL_KERN&KERN_BOOTTIME options and 2) via gettimeofday(). In both
case, struct timeval is returned, so I can compute the difference
between the two times and get the elapsed time.

I am wondering if anyone could tell me performance implications of
using sysctl() function call to obtain system boot time vs.
gettimeofday(). Is one better than the other? More efficient? Are
there advantages or disadvantages to using either of these two
methods? Any insight would be appreciated.

Thanks very much in advance,
Mari.



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