mnagel
6 years agoProfessor
Ookla Speedtest
After a few failed attempts to get this working on Windows via Powershell (works, but too inaccurate), I punted and used speedtest-cli. If I can replicate that into Groovy, then perhaps it could b...
@Cole McDonald Sure, no problem -- see below. The Ookla one is not much better in reality because the web method is not as accurate as the application socket method, but at least it tried to do bidirectional testing.
I can't claim credit for this, I found it and modified a bit to work in LM. I set the mirror site as a property since auto-selection does not work with testmy.net.
Mark
$size = 50;
$mirror = "##speedtest.testmy.mirror##";
if ($site -eq "") {
$url = "https://testmy.net/dl-${size}MB"
}
else {
$url = "https://${mirror}.testmy.net/dl-${size}MB"
}
$path = "Out-Null"
$WebClient = New-Object System.Net.WebClient
$mbps = "{0:N2}" -f (($size/(Measure-Command {$Request=Get-Date; $WebClient.DownloadFile( $url, $path )}).TotalSeconds) * ?
Write-Host "Mbps="$mbps