netdata:獲取每s的時鐘滴答
阿新 • • 發佈:2021-01-05
技術標籤:# C++
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
unsigned int system_hz;
void get_system_HZ() {
long ticks;
if ((ticks = sysconf(_SC_CLK_TCK)) == -1) {
printf("Cannot get system clock ticks");
exit(-1);
}
system_hz = (unsigned int) ticks;
}
int main(void)
{
get_system_HZ();
printf("%d\n", system_hz);
}