1

Job Batching introduced by Laravel 8 allows to execute jobs in batches and inspect Job Batch states. Illuminate\Bus\Batch instance contain such information as $createdAt, $cancelledAt, $finishedAt information.

I'm interested on inspecting the execution duration of the Job Batch (Not the duration when the Batch was created and finished/canceled, but the sum of duration of all contained Jobs).

How this approach can be implemented?

p.s. finishedAt - createdAt approach won't work, as other Batch jobs can be executed between the one Batch job (which will affect the whole duration of the Job Batch, but not the execution duration)

Yerke
  • 2,187
  • 3
  • 19
  • 33

1 Answers1

0

The jobs_batches table contains all the columns you need to calculate this.

You can calculate how fast jobs are processed since creation: (now() - created_at) / (total_jobs - pending_jobs) and then multiply this value with the pending_jobs to have the total duration based on real performance.