2

I think this is difficult thing. In general I know that I need total and current count for gaining rate to something. But in this case, I cannot get total count.

For example, there are two jobs, A and B. Their total process will be always set randomly. Also, I cannot get job's total process count before job be ended.

I have one of method that set concreted rate each jobs like if A is done, set rate 50%. But in this situation that A's count is 10 and B's count is 1000 will make strange result. Although total count is 1010, it is 50% that 10 process is done. It is something strange.

So, I want to offer more natural progress rate to users. But I don't have total process count. Is there any useful method alternative generic percentage calculation?

miniar
  • 127
  • 1
  • 8

1 Answers1

0

If you want to know how much total progress you have without knowing how much total progress there could be, this is logically impossible

However, you could

  • estimate it
  • keep historical data
  • assume the maximum and just surprise the user when it's faster

To instead show the rate of progress

  • take the current time at the start of your process and subtract the time when you check again
  • divide the completed jobs by that amount to get the jobs/second

Roughly

rate = jobs_completed / (time_now - time_start)

You can also do this over some window, but you need to record both the time and the number of jobs completed at the start of the window to subtract off both to get just the jobs in your time window

rate_windowed = (jobs_completed - jobs_previous) / (time_now - time_previous)
ti7
  • 16,375
  • 6
  • 40
  • 68