How to calculate the time of completion of the operation. While I'm in a loop with the help of StopWatch, I measure the elapsed time and calculate the average speed of one iteration. Further, the remaining number of iterations for speed ... Something results are not OK.
We have N operations that are performed in a loop.
we know that from the 1st operation to the Xth operation 10 minutes passed,
it means we have the speed V = X operations per 10 minutes = X / 10 * 60 operations per second
those. NX operations will be performed (NX) * V seconds, the actual answer)
PS if using watch you go around the cycle, then the time of your viewing is added to the real action of the operation, respectively, the speed changes ...
Windows is not a real-time operating system. Nothing prevents her from stopping the flow of your functionality for an indefinite period of time at the next moment. So display the percentage of work done.
I understand that you take the first iteration of the cycle and take it for the average processing time of one iteration. Such could prokanat in single-tasking OS. Here you need to calculate the average cycle time at each iteration. Post a piece of code, it will be easier to understand. You can try to figure it out using the theory of computational complexity: http://habrahabr.ru/post/104219/