MICROUPTIME(9)
π MICROUPTIME(9) β the manual page for getting time since boot, bestie! π
Okay so listen, this is from the MICROUPTIME(9) manual β Kernel Developer's Manual, no cap. We're talking about the iconic functions that tell you how much time has passed since the system booted up. Periodt. Let's get into it.
β¨ NAME β¨
binuptime, getbinuptime, microuptime, getmicrouptime, nanouptime, getnanouptime, sbinuptime, getsbinuptime β all of these give you the time elapsed since boot. Slay.
π 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 the way this works, bestie: binuptime() and getbinuptime() are the OGs that store the time elapsed since boot as a struct bintime at the address you pass in bt. Iconic. Then microuptime() and getmicrouptime() do the same exact thing but they record it as a struct timeval instead. And nanouptime() and getnanouptime()? They store it as a struct timespec. Cute. Finally, sbinuptime() and getsbinuptime() just return the time elapsed since boot directly as an sbintime_t. No pointer needed, we love a direct return. π
Now here's the tea: binuptime(), microuptime(), nanouptime(), and sbinuptime()? They always query the timecounter to give you the current time as precisely as possible. Highkey accurate. Whereas getbinuptime(), getmicrouptime(), getnanouptime(), and getsbinuptime() are abstractions that return a less precise but faster-to-obtain time. It's giving "speed over perfection" and honestly? Sometimes that's the vibe.
The whole intent of the get* versions is to enforce the user's preference for timer accuracy versus execution time. So like, you get to choose β do you want it fast or do you want it exact? The system respects your choice, fr fr.
π SEE ALSO π
bintime(9)get_cyclecount(9)getbintime(9)getmicrotime(9)getnanotime(9)microtime(9)nanotime(9)tvtohz(9)
Go check these out if you're obsessed with time functions like I am. π
π AUTHORS π
This manual page was written by Kelly Yancey <kbyanc@posi.net>. We stan a legend who documents kernel time functions. π«Ά
This iconic page is from the MICROUPTIME(9) manual, Debian version, dated February 21, 2015. Stay precise, bestie! πβ¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2000 Kelly Yancey
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms