Created
January 26, 2018 11:34
-
-
Save dannyc02/46918d05ed22f0a8fb76721930fb29ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Average($array) | |
{ | |
$RunningTotal = 0; | |
foreach($i in $array){ | |
$RunningTotal += $i | |
} | |
return ([decimal]($RunningTotal) / [decimal]($array.Length)); | |
} | |
$URL = "https://staging.tottenhamhotspur.com"; | |
$Times = 100; | |
$responses = New-Object System.Collections.ArrayList | |
$i = 0 | |
While ($i -lt $Times) | |
{$Request = New-Object System.Net.WebClient | |
$Request.UseDefaultCredentials = $true | |
$Start = Get-Date | |
$PageRequest = $Request.DownloadString($URL) | |
$TimeTaken = ((Get-Date) - $Start).TotalMilliseconds | |
$responses += $TimeTaken | |
$Request.Dispose() | |
Write-Host Request $i took $TimeTaken ms -ForegroundColor Green | |
$i ++} | |
$average = Average($responses); | |
Write-Host Average response took $average ms -ForegroundColor Red |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment