I'm trying to clock a sorting function, pretty straightforward stuff. Code looks like:
clock_t start_t, end_t, total_t;
start_t = clock();
sort();
end_t = clock();
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
printf("sort time: %le", (double)total_t);
You could say this works. But, no matter how long it takes I will get an integer output. If sorting 1M elements prints out
sort time: 1.000000e+00
And sorting 2M elements prints out
sort time: 2.000000e+00
Then sorting any value of elements between the two will print one of those two outputs. 1.3M elements also takes 1.000000e+00 seconds apparently.
Why is this happening and more importantly how do I fix it?