Untitled
unknown
plain_text
3 years ago
473 B
6
Indexable
#include <time.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <unistd.h> void main() { struct timespec stop, start, test; clock_gettime(CLOCK_MONOTONIC, &start); int i = 0; for (i = 0; i < 100000; i++) { clock_gettime(CLOCK_MONOTONIC, &test); } clock_gettime(CLOCK_MONOTONIC, &stop); printf("stop.tv_sec %lu nsec\n", (stop.tv_sec - start.tv_sec) * 1000000000 + stop.tv_nsec - start.tv_nsec); } //4243762 nanosec
Editor is loading...