Skip to content

Instantly share code, notes, and snippets.

@bklockwood
Last active August 29, 2015 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bklockwood/5fea04e28f4730c9a129 to your computer and use it in GitHub Desktop.
Save bklockwood/5fea04e28f4730c9a129 to your computer and use it in GitHub Desktop.
function Get-DownloadSpeed
{
[CmdletBinding()]
Param
(
# Param1 help description
[Parameter(Mandatory=$true, Position=0)]
$SpeedtestServer,
# Param2 help description
[Parameter(Mandatory=$true, Position=1)]
$DownLoad
)
Process
{
[string]$testurl = $SpeedtestServer + $DownLoad
try {
$Error = $null
$time = measure-command {$dl = Invoke-WebRequest -uri $testurl -TimeoutSec 1}
} catch {
write-host "Error downloading $testurl "
write-host $dl
break
}
$result = $($dl.RawContentLength) / $($time.totalseconds)
$resultmb = $result / 1000000
$resultmb = [math]::Round($resultmb,2) #round to 2 decimal places
$dlmb = $($dl.RawContentLength) / 1000000
$dlmb = [math]::Round($dlmb,2)
$secs = $($time.totalseconds)
$secs = [math]::Round($secs,2)
Write-host "$testurl downloaded $dlmb Mbit in $secs seconds at $resultmb Mbit/s"
}
}
$dl500 = "/speedtest/random500x500.jpg"
$dl1000 = "/speedtest/random1000x1000.jpg"
$dl2000 = "/speedtest/random2000x2000.jpg"
$testserver = "www.irongoat.net/speedtest"
#Get-DownloadSpeed $testserver $dl500
#Get-DownloadSpeed $testserver $dl1000
Get-DownloadSpeed $testserver $dl2000
@bklockwood
Copy link
Author

A typical response:

www.irongoat.net/speedtest/speedtest/random2000x2000.jpg downloaded 7.91 Mbit in 2.51 seconds at 3.15 Mbit/s

Using the speedtest.net web interface pointed at this same server, 70Mbit/sec results are common. Never as low as 3Mbit/sec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment