HPL_ptimer_cputime(3)

πŸ“¦ version 2.2, in fedora 43, fedora 44

πŸ’– HPL_ptimer_cputime β€” bestie edition πŸ’–

okay so you're in the HPL library functions section (HPL_ptimer_cputime(3), hey girl hey πŸ‘‘), and this lil cutie is all about returning the CPU time. that's it, that's the whole vibe. let's get into it 🫢


✨ NAME ✨

HPL_ptimer_cputime β€” returns the CPU time. literally her whole job πŸ’…


🌸 SYNOPSIS 🌸

#include "hpl.h"

double HPL_ptimer_cputime();

yes bestie, she takes no arguments and hands you back a double. no thoughts, just time ⏱️


πŸ¦‹ DESCRIPTION πŸ¦‹

so HPL_ptimer_cputime returns the cpu time. simple. elegant. iconic.

but how she gets it? that depends on what you defined, and this is the part where you gotta pay attention πŸ‘€

  • if HPL_USE_CLOCK is defined β€” the clock() function is used to return an approximation of processor time used by the program. the value returned is the CPU time used so far as a clock_t; and to get the number of seconds used, the result is divided by CLOCKS_PER_SEC. and fun fact bestie: this function is part of the ANSI/ISO C standard library ✨
  • if HPL_USE_TIMES is defined β€” the times() function is used instead. this function returns the current process times. times() returns the number of clock ticks that have elapsed since the system has been up 🌈
  • otherwise, and by default β€” the standard library function getrusage() is used πŸ’œ

so like, three possible routes, one adorable little double at the end of it. the way that she adapts?? obsessed 😭

ngl bestie, make sure you know which macro you're compiling with, because the answer you get comes from a different function depending on it. no cap πŸ’€

πŸŽ€ SEE ALSO πŸŽ€

  • HPL_ptimer_walltime (3) β€” for when you want the wall-clock bestie instead πŸ•°οΈ
  • HPL_ptimer (3) β€” the main character of the timer family πŸ‘‘

and that's the whole page, periodt πŸ’– this was HPL version 2.2, dated February 24, 2016 β€” so she's been serving accurate CPU time since way back, and she still ate fr fr πŸ“πŸ§šβœ¨

πŸ“¦ where this page comes from