MICROUPTIME(9)

πŸ’– MICROUPTIME(9) πŸ’–

okay bestie, so this is the microuptime family of kernel functions from the Kernel Developer's Manual β€” yes, the manual is literally called MICROUPTIME(9), iconic name, no notes. it's all about asking the kernel "hey how long has it been since we booted??" and getting an answer back in whatever time format you vibe with. 🌸


✨ SYNOPSIS ✨

#include <sys/time.h>

void
binuptime(struct bintime *bt);

void
getbinuptime(struct bintime *bt);

void
microuptime(struct timeval *tv);

void
getmicrouptime(struct timeval *tv);

void
nanouptime(struct timespec *ts);

void
getnanouptime(struct timespec *tsp);

sbintime_t
sbinuptime(void);

sbintime_t
getsbinuptime(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, every single one of these is giving "time elapsed since boot" energy. they just format it differently, and some of them are the ✨precise✨ girlies while others are the ✨fast✨ girlies. let's break it down:

  • binuptime() and getbinuptime() β€” these two store the time elapsed since boot as a struct bintime, and they put it at the address that bt points to. πŸŽ€
  • microuptime() and getmicruoptime()... wait no, getmicrouptime() β€” same whole entire job, but they record the elapsed time as a struct timeval instead. different format, same truth.
  • nanouptime() and getnanouptime() β€” you already know the pattern, bestie. these store the elapsed time as a struct timespec. one takes ts, the other takes tsp (yes they're spelled differently, don't come for me, that's just how it is πŸ’…).
  • sbinuptime() and getsbinuptime() β€” these two just straight up return the time elapsed since boot as an sbintime_t. no pointer, no address, just vibes and a return value. periodt.

πŸ”₯ the precision girlies vs. the speed girlies πŸ”₯

okay this is the part that actually matters, so listen up:

  • binuptime(), microuptime(), nanouptime(), and sbinuptime() β€” these always query the timecounter, so you get the current time as precisely as possible. they're the ones doing the full glam routine. πŸ’–
  • getbinuptime(), getmicrouptime(), getnanouptime(), and getsbinuptime() β€” these are abstractions that return a less precise, but faster to obtain, time. they're the "good enough, I'm running late" option. πŸƒβ€β™€οΈπŸ’¨
ngl, the whole point of the get-prefixed ones is to enforce the user's preference for timer accuracy versus execution time. so like, the system has a setting, and these respect it. you get what you asked for, bestie. 🫢

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Kelly Yancey <kbyanc@posi.net>. absolute legend behavior, we love to see it. πŸ’œ


and that's the whole page, bestie!! this came to you from the Debian edition of the Kernel Developer's Manual, dated February 21, 2015, filed under MICROUPTIME(9) β€” go forth and measure your uptime with confidence. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from