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 MICROTIME 9 29ae5ccfadSAlexey Zelkin.Os FreeBSD 30ae5ccfadSAlexey Zelkin.Sh NAME 31ae5ccfadSAlexey Zelkin.Nm microtime , 32ae5ccfadSAlexey Zelkin.Nm getmicrotime , 33ae5ccfadSAlexey Zelkin.Nm nanotime , 34ae5ccfadSAlexey Zelkin.Nm getnanotime 35ae5ccfadSAlexey Zelkin.Nd get the current time 36ae5ccfadSAlexey Zelkin.Sh SYNOPSIS 37ae5ccfadSAlexey Zelkin.Fd #include <sys/time.h> 38ae5ccfadSAlexey Zelkin.Ft void 39ae5ccfadSAlexey Zelkin.Fn microtime "struct timeval *tv" 40ae5ccfadSAlexey Zelkin.Ft void 41ae5ccfadSAlexey Zelkin.Fn getmicrotime "struct timeval *tv" 42ae5ccfadSAlexey Zelkin.Ft void 43ae5ccfadSAlexey Zelkin.Fn nanotime "struct timespec *ts" 44ae5ccfadSAlexey Zelkin.Ft void 45ae5ccfadSAlexey Zelkin.Fn getnanotime "struct timespec *tsp" 46ae5ccfadSAlexey Zelkin.Sh DESCRIPTION 47ae5ccfadSAlexey ZelkinThe 48ae5ccfadSAlexey Zelkin.Fn microtime 49ae5ccfadSAlexey Zelkinand 50ae5ccfadSAlexey Zelkin.Fn getmicrotime 51ae5ccfadSAlexey Zelkinfunctons stores the system time as a 52ae5ccfadSAlexey Zelkin.Ft struct timeval 53ae5ccfadSAlexey Zelkinat the address specified by 54ae5ccfadSAlexey Zelkin.Fa tv . 55ae5ccfadSAlexey ZelkinThe 56ae5ccfadSAlexey Zelkin.Fn nanotime 57ae5ccfadSAlexey Zelkinand 58ae5ccfadSAlexey Zelkin.Fn getnanotime 59ae5ccfadSAlexey Zelkinfunctions perform the same utility, but record the time as a 60ae5ccfadSAlexey Zelkin.Ft struct timespec 61ae5ccfadSAlexey Zelkininstead. 62ae5ccfadSAlexey Zelkin.Pp 63ae5ccfadSAlexey Zelkin.Fn Microtime 64ae5ccfadSAlexey Zelkinand 65ae5ccfadSAlexey Zelkin.Fn nanotime 66ae5ccfadSAlexey Zelkinalways query the timecounter to return the current time as precisely as 671111b49cSSheldon Hearnpossible. 681111b49cSSheldon HearnWhereas 69ae5ccfadSAlexey Zelkin.Fn getmicrotime 70ae5ccfadSAlexey Zelkinand 71ae5ccfadSAlexey Zelkin.Fn getnanotime 72ae5ccfadSAlexey Zelkinfunctions are abstractions which can alternately return a less precise, but 731111b49cSSheldon Hearnfaster to obtain, time. 741111b49cSSheldon HearnThis behaviour can be toggled via the 75ae5ccfadSAlexey Zelkinkern.timecounter.method sysctl variable: 76ae5ccfadSAlexey Zelkin.Bl -tag -width ABC 77ae5ccfadSAlexey Zelkin.It Dv 0 78ae5ccfadSAlexey Zelkinsacrifice precision in favor of faster code execution 79ae5ccfadSAlexey Zelkin.It Dv 1 80ae5ccfadSAlexey Zelkinreturn the more precise time (the same as calling 81ae5ccfadSAlexey Zelkin.Fn microtime 82ae5ccfadSAlexey Zelkinor 83ae5ccfadSAlexey Zelkin.Fn nanotime ) . 84ae5ccfadSAlexey Zelkin.El 85ae5ccfadSAlexey Zelkin.Pp 86ae5ccfadSAlexey ZelkinThe intent of the 87ae5ccfadSAlexey Zelkin.Fn getmicrotime 88ae5ccfadSAlexey Zelkinand 89ae5ccfadSAlexey Zelkin.Fn getnanotime 90ae5ccfadSAlexey Zelkinfunctions is to enforce the user's preference for timer accuracy versus 91ae5ccfadSAlexey Zelkinexecution time. 92ae5ccfadSAlexey Zelkin.Sh SEE ALSO 93ae5ccfadSAlexey Zelkin.Xr getmicrouptime 9 , 94ae5ccfadSAlexey Zelkin.Xr getnanouptime 9 , 95ae5ccfadSAlexey Zelkin.Xr microuptime 9 , 96ae5ccfadSAlexey Zelkin.Xr nanouptime 9 , 97ae5ccfadSAlexey Zelkin.Xr tvtohz 9 98ae5ccfadSAlexey Zelkin.Sh DIAGNOSTICS 99ae5ccfadSAlexey ZelkinBuggy hardware can cause "calcru negative..." when kern.timecounter.method 100ae5ccfadSAlexey Zelkinis set to 0. 101ae5ccfadSAlexey Zelkin.Sh HISTORY 102ae5ccfadSAlexey ZelkinThe 103ae5ccfadSAlexey Zelkin.Nm microtime 104ae5ccfadSAlexey Zelkinand 105ae5ccfadSAlexey Zelkin.Nm nanotime 106ae5ccfadSAlexey Zelkinfunctions first appeared in 107ae5ccfadSAlexey Zelkin.Fx 3.0 108ae5ccfadSAlexey Zelkinbut existed in other incarnations since 109ae5ccfadSAlexey Zelkin.Bx 4.4 110ae5ccfadSAlexey Zelkin.Sh AUTHORS 111ae5ccfadSAlexey ZelkinThis manual page was written by 112ae5ccfadSAlexey Zelkin.An Kelly Yancey Aq kbyanc@posi.net . 113