How to measure execution time for background jobs?

Welcome Forums General PowerShell Q&A How to measure execution time for background jobs?

This topic contains 2 replies, has 3 voices, and was last updated by

2 years, 12 months ago.

  • Author
  • #11535

    Topics: 3
    Replies: 2
    Points: 0
    Rank: Member

    I would like to compare my script execution performance with and without running background jobs.
    Measure-command snippets provide required data for script without running jobs,

    Is there any snippet available for measuring background job performance.


  • #40448

    Topics: 0
    Replies: 1
    Points: 0
    Rank: Member

    So, I'm very sorry to revive this very old thread, but several Google searches let me here.

    Here's what I figured out, about trying to measure background job performance.

    It's actually stored as part of the job!

    Here's what I did:
    Ran a job. It showed up as "Job1".
    When it was complete, I ran:

     ((Get-Job Job1).PSEndTime.TimeOfDay - (Get-Job Job1).PSBeginTime.TimeOfDay).TotalMinutes

    To explore what else is available, use Get-Member. So run:

    ((Get-Job Job1).PSBeginTime.TimeOfDay) | Get-Member

    Hope this helps someone!

  • #11553

    Topics: 0
    Replies: 4
    Points: 0
    Rank: Member

    Perhaps you could encapsulate the Measure-Command scriptblock to include the following expression:

    1. Start-Job.
    2. Loop that waits 1 second and does Get-Job to see if it's running.
    3. When it is not running, exit the loop and finish the script.

    I think that would work for you.

The topic ‘How to measure execution time for background jobs?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort