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.

  • one
    Give better code, and better its simplified version. "In a loop" and "one iteration rate" together look suspicious. - VladD

3 answers 3

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 ...

  • one
    "it means we have a speed of V = X operations per 10 minutes = X * 10 * 60 operations per second" Logic tells me that the speed is calculated as V = X / 10 * 60 or is I wrong? - Sergue Isupov
  • oh, you're right) - IVsevolod

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.

  • Special accuracy is not important to me. I export from one database to another. So it is unlikely that an error even in seconds (minutes) will worsen my result. - Sergue Isupov

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/

  • 2
    A great example of bullshit. Suppose you have a function that implements a certain algorithm for which its algorithmic complexity ‛O (N)‛ is strictly proved under a uniform weight criterion. Please calculate how long it will take to run this function 300 times for datasets of known dimension. - Costantino Rupert
  • No, I consider the average time to complete one iteration. It seems that I got an acceptable result. Perhaps there was a rounding error in dividing. I have already tried a million options. - Sergue Isupov