Average Rating:

2.00 by 2 users.

48 Downloads, 197 Views

1 Comment(s)

2011sg_B10.ps1

By: Dan 22 Apr 2011 12:48 AM UTC in the category: Beginner Event 10

Param([int]$Loops = 5,
      [int]$Pause = 5)
      
$Total = 0

For ([int]$int = 1; $int -le $Loops; $int ++){
    $Start = Get-date
    Start-Sleep $pause
    $End = Get-Date
    $Diff = ($End.Subtract($Start)).TotalMilliseconds
    $Total = $Total + $Diff
    }

Write-host "Average time of $Loops runs of $Pause seconds is"($Total/$Loops)"milliseconds"

Top

Comments:

4/23/2011 11:04 PM
Nice and simple. Try playing with the MEASURE-COMMAND Cmdlet - It will eliminate most of the code :)