I am trying to measure the running time in nanoseconds of a function by using clock()
function, like this:
clock_t start_t = clock();
random_function();
clock_t end_t = clock();
printf("Elapsed time: %f\n", (double)(end_t - start_t) / CLOCKS_PER_SEC);
When I run the program I sometimes get very big negative numbers as a result. Why does this happen?