You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
proxysql/test/monot.cpp

27 lines
441 B

#include <time.h>
#include <stdio.h>
#include <unistd.h>
long monotonic_time() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (((long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
}
#define LOOPS 10000000
int main() {
volatile int i;
volatile long l;
struct timespec req;
req.tv_sec=0;
req.tv_nsec=1;
for (i=0;i<LOOPS;i++) {
//usleep(1);
//nanosleep(&req, NULL);
l=monotonic_time();
}
return 0;
}