Skip to content

Instantly share code, notes, and snippets.

@dannyc02
Created January 26, 2018 11:34
Show Gist options
  • Save dannyc02/46918d05ed22f0a8fb76721930fb29ae to your computer and use it in GitHub Desktop.
Save dannyc02/46918d05ed22f0a8fb76721930fb29ae to your computer and use it in GitHub Desktop.
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