#include <stdio.h>
#include <time.h>
#include <stdint.h>
int main() {
// Record start time
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < 1000; i++);
// Record end time
clock_gettime(CLOCK_MONOTONIC, &end);
// Calculate time difference in nanoseconds
int64_t time_in_nanoseconds =
(int64_t)(end.tv_sec - start.tv_sec) * 1000000000 +
(end.tv_nsec - start.tv_nsec);
printf("%ld [ns]\n", time_in_nanoseconds);
return 0;
}
/*
run:
751 [ns]
*/