It seems right to me, unless I am totally missing something obvious.

The original code had timeout=1000 and a usleep(10000) for each iteration while decreasing timeout by 1 on each iteration for a total of 1000 iterations. That leads me to think the total time is 1000x10000 microseconds = 10 seconds(although the comment incorrectly? said 5 seconds).

So, using that logic - I get 2000X1000 microseconds for my change, which is 2 seconds and what I put in the comment.

I am not seeing how the time could be half of what I calculate.