MICROTIME(9)

πŸ’– MICROTIME(9) πŸ’–

okay bestie, this is a section 9 kernel dev page (that's the Kernel Developer's Manual, iykyk) and it's all about ✨getting the current time✨. Six little functions, all serving the same cunty purpose, just different flavours of it.


🌸 NAME 🌸

bintime, getbintime, microtime, getmicrotime, nanotime, getnanotime β€” get the current time πŸ•


✨ SYNOPSIS ✨

#include <sys/time.h>

void
bintime(struct bintime *bt);

void
getbintime(struct bintime *bt);

void
microtime(struct timeval *tv);

void
getmicrotime(struct timeval *tv);

void
nanotime(struct timespec *ts);

void
getnanotime(struct timespec *tsp);

πŸŽ€ DESCRIPTION πŸŽ€

So here's the tea, bestie. 🍡

bintime() and getbintime() store the system time as a struct bintime at the address you give them in bt. microtime() and getmicrotime() do the exact same little job but they record the time as a struct timeval instead. And nanotime() and getnanotime()? Yeah they're storing the time as a struct timespec. Same energy, different struct. πŸ’…

Now here's the part that matters:

  • bintime(), microtime(), and nanotime() always query the timecounter, so you get the current time as precisely as possible. No cap. πŸ‘‘
  • getbintime(), getmicrotime(), and getnanotime() are the abstractions β€” they return a time that's less precise but faster to obtain. Tradeoff queen behaviour. πŸ¦‹

And the whole intent of the get-flavoured ones? It's to enforce the user's preference for timer accuracy versus execution time. Like, you said you wanted speed over precision, so bestie, the kernel is respecting that. 🫢


🌈 SEE ALSO 🌈

(go read those too, they're the uptime girlies πŸ’–)


πŸ’œ HISTORY πŸ’œ

The bintime functions first appeared in FreeBSD 5.0. The microtime and nanotime functions first appeared in FreeBSD 3.0 but have existed in other incarnations since 4.4BSD. iconic lineage honestly, they've been serving since forever πŸ’€βœ¨


⭐ AUTHORS ⭐

This manual page was written by Kelly Yancey <kbyanc@posi.net>. tysm queen πŸŽ€


πŸ’… and that's the whole page, no skips, no crumbs left behind

Debian β€’ September 16, 2004 β€’ MICROTIME(9) β€” mwah, love u, go read binuptime(9) next πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from