PMTIMESPECNOW(3)

πŸ“¦
version 6.3.8 Β· 3 versions
, in centos-stream 9, debian trixie, ubuntu questing

✨ PMTIMESPECNOW(3) ✨

okay bestie so this one is from PCP (Performance Co-Pilot) and it lives in the Library Functions Manual section 3, and it's literally just a lil friend group of helpers for handling time when it's stored as a struct timespec πŸ•°οΈπŸ’–


🌸 NAME 🌸

pmtimespecNow, pmtimespecInc, pmtimespecDec, pmtimespecAdd, pmtimespecSub, pmtimespecToReal, pmtimespecFromReal, pmPrintHighResStamp β€” helper routines for time stored as a struct timespec ✨


πŸŽ€ C SYNOPSIS πŸŽ€

like, include the header first obviously:

#include <pcp/pmapi.h>

and here's the whole squad, character for character πŸ’…

void pmtimespecNow(struct timespec *tp);
void pmtimespecInc(struct timespec *ap, const struct timespec *bp);
void pmtimespecDec(struct timespec *ap, const struct timespec *bp);
double pmtimespecAdd(const struct timespec *ap, const struct timespec *bp);
double pmtimespecSub(const struct timespec *ap, const struct timespec *bp);
double pmtimespecToReal(const struct timespec *tp);
void pmtimespecFromReal(double secs, struct timespec *tp);
void pmPrintHighResStamp(FILE *f, const struct timespec *tp);

and you gotta link it up:

cc ... -lpcp

πŸ¦‹ DESCRIPTION πŸ¦‹

⭐ pmtimespecNow

pmtimespecNow is the platform-independent method that returns the current system time since the Epoch in tp. no cap, it just goes and gets you the now πŸ•βœ¨

⭐ pmtimespecInc and pmtimespecDec

pmtimespecInc adds the time in ap to the time in bp and stores the result in ap. and pmtimespecDec is the reverse vibe β€” it subtracts the time in bp from the time in ap and stores the result in ap. notice how the answer always lands back in ap? that's the main character of these two πŸ’…

⭐ pmtimespecAdd and pmtimespecSub

pmtimespecAdd (and pmtimespecSub) add (and subtract) times and return the result as a double value. the time in the ap argument is not changed β€” she stays exactly as she was, unbothered, moisturized, in her lane πŸ§–β€β™€οΈβœ¨

⭐ pmtimespecToReal and pmtimespecFromReal

pmtimespecToReal converts the time in tp to an equivalent double value. and pmtimespecFromReal gives you the reverse conversion β€” it takes the time in secs and returns the equivalent time in tp. it's giving two-way street, it's giving reciprocity 🫢

⭐ pmPrintHighResStamp

pmPrintHighResStamp prints the timestamp from tp on the stream f in the local time (as returned by pmLocaltime(3)) in the format HH:MM:SS.XXXXXXXXX. that's a whole lotta decimal places and honestly? she earned them πŸ”₯


πŸ’œ NOTES πŸ’œ

for variants of these interfaces using microsecond precision and the timeval structure, go check out pmtimevalNow(3). different struct, same energy πŸ¦‹


🌈 SEE ALSO 🌈


Performance Co-Pilot Β· PCP Β· PMTIMESPECNOW(3) β€” mwah, that's the whole page bestie, go forth and timestamp responsibly πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from