Timer in C

Hello,

It seems my call to the timer in C always returns 0 in the Codingame interface.

To get the timer in ms, I am calling clock() * 1000 / CLOCKS_PER_SEC.

Am I missing something ?

Thanks in advance!

David

You are perhaps under 1ms of execution time and display it as an int…and it’s rounded to zero.

Try this :
clock_t start, end;
start = clock();
// Your code
end = clock();
printf("%f\n", (end - start) * 1000.f / CLOCKS_PER_SEC); // as a float

1 Like

Well i m here for the same. I tried it by your way, it’s perfect to solve it. Thanks