title: How to calculate overall computation time for a multi-threaded process
body: <p>I have a set of tasks, let's call it <code>T[]</code>, where each task <code>T[i]</code> needs a certain amount of time <code>t(T[i])</code> to be processed. The tasks are being processed in parallel by <code>X</code> threads (that is not to mean that multiple threads are co-working on a single task, but that multiple tasks are being processed by multiple threads, each thread doing one task, then the next, etc). </p>
  
  <p>Now I want to calculate the expected overall time it will take to process all tasks. It's easy as long as <code>size(T[]) &lt;= X</code> of course (i.e. the number of tasks is less than or equal to the number of threads), in this case the overall time equals the time of the slowest task.</p>
  
  <p>But I'm quite lost for the case <code>X &lt; size(T[])</code> (i.e. I have fewer threads than tasks). How would one calculate that in an elegant way?</p>
  
  <p>edit: As asked by a commentator, we can assume the tasks queue is ordered by longest-running task first, shortest-running task last. Also, we can assume there is no pauses between tasks, and we can also neglect what the OS scheduler is doing.</p>