Created
March 2, 2016 08:02
-
-
Save tshm/323f2c8cc68cc84f6c2a to your computer and use it in GitHub Desktop.
web performance
This file contains hidden or 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
# 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