Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C linux equivalent of windows QueryPerformanceCounter

Tags:

c

linux

cpu

winapi

Is there an equivalent C function in linux for reading the CPU counter and its frequency?

I am looking for something similair to QueryPerformanceCounter function that reads the 64bit counter in modern CPU's

like image 236
myforwik Avatar asked Apr 17 '10 07:04

myforwik


2 Answers

clock_gettime(2), with an argument of CLOCK_REALTIME_HR.

like image 184
Ignacio Vazquez-Abrams Avatar answered Oct 27 '22 01:10

Ignacio Vazquez-Abrams


clock_gettime() with CLOCK_MONOTONIC_RAW

like image 36
ivan.ukr Avatar answered Oct 27 '22 01:10

ivan.ukr