PMTIMEVALNOW(3)

πŸ’– PMTIMEVALNOW(3) β€” the struct timeval bestie squad πŸ’–

Library Functions Manual energy, but make it a group chat. Okay so this page lives in the PCP corner of your system and it's all about the little helper routines that do math on time stored as a struct timeval. Yes, the tv_sec/tv_usec one. We love her. πŸ•°οΈβœ¨


🌸 NAME 🌸

pmtimevalNow, pmtimevalInc, pmtimevalDec, pmtimevalAdd, pmtimevalSub, pmtimevalToReal, pmtimevalFromReal, pmtimevalTotimespec, pmtimevalPrint β€” the helper routines for time stored as a struct timeval. 🫢


✨ C SYNOPSIS ✨

#include <pcp/pmapi.h>

void pmtimevalNow(struct timeval *tv);
void pmtimevalInc(struct timeval *ap, const struct timeval *bp);
void pmtimevalDec(struct timeval *ap, const struct timeval *bp);
double pmtimevalAdd(const struct timeval *ap, const struct timeval *bp);
double pmtimevalSub(const struct timeval *ap, const struct timeval *bp);
double pmtimevalToReal(const struct timeval *val);
void pmtimevalFromReal(double secs, struct timeval *val);
void pmtimevalTotimespec(struct timeval *tvp, struct timespec *tsp);
void pmtimevalPrint(FILE *f, const struct timeval *tp);

cc ... -lpcp

Link her up with -lpcp or she simply will not exist, bestie. 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

So. The way that all these functions are literally just little time-gremlins doing math for you? Iconic.

  • pmtimevalNow is the platform-independent queen πŸ‘‘ β€” she hands you the current system time since the Epoch in tv.
  • pmtimevalInc adds the time in ap to the time in bp and stores the result in ap. And pmtimevalDec does the same vibe but backwards β€” it subtracts the time in bp from the time in ap, and yes, the result lands back in ap. She's an in-place girlie. πŸ’…
  • pmtimevalAdd (and pmtimevalSub) add (and subtract) times and return the result as a double value. The time in the ap argument is not changed β€” she would never do that to you, no cap. πŸŽ€
  • pmtimevalToReal converts the time in tp to an equivalent double value. And pmtimevalFromReal is the reverse conversion, taking the time in secs and returning the equivalent time in val. It's giving glow-up, it's giving transformation. πŸ¦‹βœ¨
  • pmtimevalTotimespec converts the struct timeval tvp into an equivalent struct timespec tsp (modulo rounding microseconds up to nanoseconds). Microscopic rounding behavior, but she's honest about it. πŸ™ˆ
  • pmtimevalPrint prints the timestamp from tp on the stream f in the local time (as returned by pmLocaltime(3)) in the format HH:MM:SS.XXX. Slay. ⏰

πŸ“ NOTES πŸ“

For variants of these interfaces using nanosecond precision and the timespec structure, refer to pmtimespecNow(3). She's the high-precision sister, iykyk. ⭐


πŸ’€ COMPATIBILITY πŸ’€

Bestie. Listen. Read this part. πŸ‘€

Prior to PCP 7.0 the routine pmtimevalPrint was called pmPrintStamp. To support PMAPI transition, the old routine can still be used if applications are recompiled with -DPMAPI_VERSION=2.

pmPrintStamp is now deprecated and compile-time support for this routine name will be removed in a future release. So like… it still works, but she's on her way out. Do not get attached. 😭πŸͺ¦


πŸ‘€ SEE ALSO πŸ‘€

gettimeofday(2), time(2), PMAPI(3), pmLocaltime(3) and pmtimespecNow(3).


okay that's the whole page bestie you ATE that reading comprehension moment, go touch some grass and come back when you need to do time math πŸ’–πŸŒˆ

Performance Co-Pilot 🫢 PCP 🫢 PMTIMEVALNOW(3) β€” mwah, stan, signing off, no cap. πŸ’…πŸŽ€

πŸ“¦ where this page comes from