1ae5ccfadSAlexey Zelkin.\" Copyright (c) 2000 Kelly Yancey 2ae5ccfadSAlexey Zelkin.\" All rights reserved. 3ae5ccfadSAlexey Zelkin.\" 4ae5ccfadSAlexey Zelkin.\" Redistribution and use in source and binary forms, with or without 5ae5ccfadSAlexey Zelkin.\" modification, are permitted provided that the following conditions 6ae5ccfadSAlexey Zelkin.\" are met: 7ae5ccfadSAlexey Zelkin.\" 1. Redistributions of source code must retain the above copyright 8ae5ccfadSAlexey Zelkin.\" notice, this list of conditions and the following disclaimer. 9ae5ccfadSAlexey Zelkin.\" 2. Redistributions in binary form must reproduce the above copyright 10ae5ccfadSAlexey Zelkin.\" notice, this list of conditions and the following disclaimer in the 11ae5ccfadSAlexey Zelkin.\" documentation and/or other materials provided with the distribution. 12ae5ccfadSAlexey Zelkin.\" 13ae5ccfadSAlexey Zelkin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14ae5ccfadSAlexey Zelkin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15ae5ccfadSAlexey Zelkin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16ae5ccfadSAlexey Zelkin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17ae5ccfadSAlexey Zelkin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18ae5ccfadSAlexey Zelkin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19ae5ccfadSAlexey Zelkin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20ae5ccfadSAlexey Zelkin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21ae5ccfadSAlexey Zelkin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22ae5ccfadSAlexey Zelkin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23ae5ccfadSAlexey Zelkin.\" SUCH DAMAGE. 24ae5ccfadSAlexey Zelkin.\" 25ae5ccfadSAlexey Zelkin.\" $FreeBSD$ 26ae5ccfadSAlexey Zelkin.\" 27ae5ccfadSAlexey Zelkin.Dd January 3, 2000 28ae5ccfadSAlexey Zelkin.Dt MICROUPTIME 9 29ae5ccfadSAlexey Zelkin.Os FreeBSD 30ae5ccfadSAlexey Zelkin.Sh NAME 31ae5ccfadSAlexey Zelkin.Nm microuptime , 32ae5ccfadSAlexey Zelkin.Nm getmicrouptime , 33ae5ccfadSAlexey Zelkin.Nm nanouptime , 34ae5ccfadSAlexey Zelkin.Nm getnanouptime 35ae5ccfadSAlexey Zelkin.Nd get the time elapsed since boot 36ae5ccfadSAlexey Zelkin.Sh SYNOPSIS 37ae5ccfadSAlexey Zelkin.Fd #include <sys/time.h> 38ae5ccfadSAlexey Zelkin.Ft void 39ae5ccfadSAlexey Zelkin.Fn microuptime "struct timeval *tv" 40ae5ccfadSAlexey Zelkin.Ft void 41ae5ccfadSAlexey Zelkin.Fn getmicrouptime "struct timeval *tv" 42ae5ccfadSAlexey Zelkin.Ft void 43ae5ccfadSAlexey Zelkin.Fn nanouptime "struct timespec *ts" 44ae5ccfadSAlexey Zelkin.Ft void 45ae5ccfadSAlexey Zelkin.Fn getnanouptime "struct timespec *tsp" 46ae5ccfadSAlexey Zelkin.Sh DESCRIPTION 47ae5ccfadSAlexey ZelkinThe 48ae5ccfadSAlexey Zelkin.Fn microuptime 49ae5ccfadSAlexey Zelkinand 50ae5ccfadSAlexey Zelkin.Fn getmicrouptime 51ae5ccfadSAlexey Zelkinfunctions store the time elapsed since boot as a 52ae5ccfadSAlexey Zelkin.Ft struct timeval 53ae5ccfadSAlexey Zelkinat the address specified by 54ae5ccfadSAlexey Zelkin.Fa tv . 55ae5ccfadSAlexey ZelkinThe 56ae5ccfadSAlexey Zelkin.Fn nanouptime 57ae5ccfadSAlexey Zelkinand 58ae5ccfadSAlexey Zelkin.Fn getnanouptime 59ae5ccfadSAlexey Zelkinfunctions perform the same utility, but record the elapsed time as a 60ae5ccfadSAlexey Zelkin.Ft struct timespec 61ae5ccfadSAlexey Zelkininstead. 62ae5ccfadSAlexey Zelkin.Pp 63ae5ccfadSAlexey Zelkin.Fn Microuptime 64ae5ccfadSAlexey Zelkinand 65ae5ccfadSAlexey Zelkin.Fn nanouptime 66ae5ccfadSAlexey Zelkinalways query the timecounter to return the current time as precisely as 67ae5ccfadSAlexey Zelkinpossible. Whereas 68ae5ccfadSAlexey Zelkin.Fn getmicrouptime 69ae5ccfadSAlexey Zelkinand 70ae5ccfadSAlexey Zelkin.Fn getnanouptime 71ae5ccfadSAlexey Zelkinfunctions are abstractions which can alternately return a less precise, but 72ae5ccfadSAlexey Zelkinfaster to obtain, time. This behaviour can be toggled via the 73ae5ccfadSAlexey Zelkinkern.timecounter.method sysctl variable: 74ae5ccfadSAlexey Zelkin.Bl -tag -width ABC 75ae5ccfadSAlexey Zelkin.It Dv 0 76ae5ccfadSAlexey Zelkinsacrifice precision in favor of faster code execution 77ae5ccfadSAlexey Zelkin.It Dv 1 78ae5ccfadSAlexey Zelkinreturn the more precise time (the same as calling 79ae5ccfadSAlexey Zelkin.Fn microuptime 80ae5ccfadSAlexey Zelkinor 81ae5ccfadSAlexey Zelkin.Fn nanouptime ) . 82ae5ccfadSAlexey Zelkin.El 83ae5ccfadSAlexey Zelkin.Pp 84ae5ccfadSAlexey ZelkinThe intent of the 85ae5ccfadSAlexey Zelkin.Fn getmicrouptime 86ae5ccfadSAlexey Zelkinand 87ae5ccfadSAlexey Zelkin.Fn getnanouptime 88ae5ccfadSAlexey Zelkinfunctions is to enforce the user's preference for timer accuracy versus 89ae5ccfadSAlexey Zelkinexecution time. 90ae5ccfadSAlexey Zelkin.Sh SEE ALSO 91ae5ccfadSAlexey Zelkin.Xr getmicrotime 9 , 92ae5ccfadSAlexey Zelkin.Xr getnanotime 9 , 93ae5ccfadSAlexey Zelkin.Xr microtime 9 , 94ae5ccfadSAlexey Zelkin.Xr nanotime 9 , 95ae5ccfadSAlexey Zelkin.Xr tvtohz 9 96ae5ccfadSAlexey Zelkin.Sh DIAGNOSTICS 97ae5ccfadSAlexey ZelkinBuggy hardware can cause "calcru negative..." when kern.timecounter.method 98ae5ccfadSAlexey Zelkinis set to 0. 99ae5ccfadSAlexey Zelkin.Sh AUTHORS 100ae5ccfadSAlexey ZelkinThis manual page was written by 101ae5ccfadSAlexey Zelkin.An Kelly Yancey Aq kbyanc@posi.net . 102