I\'ve got a piece of userspace code which is parsing /proc/PID/task/TID/stat to get the cpu usage. I can use HZ to get the jiffies per second but this code could move to an
For shell-scripting, etc, use getconf CLK_TCK
from the command-line. Use can use this to pass that parameter in as an environment variable or on the command-line.
main(int argc, char **argv) {
unsigned long clk_tck = atol(
getenv("CLK_TCK") || "0"
) || sysconf(_SC_CLK_TCK) ;
... /* your code */
This uses the sysconf as above, but allows you to override it with an environment variable, which can be set with the above command.