Skip to content

Instantly share code, notes, and snippets.

@tshm
Created March 2, 2016 08:02
Show Gist options
  • Save tshm/323f2c8cc68cc84f6c2a to your computer and use it in GitHub Desktop.
Save tshm/323f2c8cc68cc84f6c2a to your computer and use it in GitHub Desktop.
web performance
# network connection test script.
$url = "http://www.google.com/"
$sleep = 1
function test() {
try {
$meas = Measure-Command {
$response = Invoke-WebRequest $url
}
$time = [Math]::Round($meas.TotalMilliseconds)
if (-not $response.statuscode -eq 200) { $time = -1 }
} catch {
$time = -1
}
return $time
}
while(1) {
$clock = (Get-Date).ToString()
$time = test
$mes = "$clock`t$time"
Write-Output $mes
[Console]::Error.WriteLine($mes)
Start-Sleep -Seconds $sleep
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment