Update SpeedTest.ps1
This commit is contained in:
1 parent
805748a00f
commit
bdbcb439bb
1 file changed
+10
-9
+10
-9
@@ -8,21 +8,22 @@ param(
|
|||||||
|
|
||||||
Write-Host "Initializing HTTPS speed test via Cloudflare CDN..." -ForegroundColor Cyan
|
Write-Host "Initializing HTTPS speed test via Cloudflare CDN..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# 1. Latency (TTFB probe)
|
|
||||||
$wc = New-Object System.Net.WebClient
|
$wc = New-Object System.Net.WebClient
|
||||||
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
|
||||||
|
# IP Address Detection
|
||||||
try {
|
try {
|
||||||
$null = $wc.DownloadString("https://speed.cloudflare.com/meta")
|
$internalIP = (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias * | Where-Object { $_.IPAddress -notlike "127.*" -and $_.IPAddress -notlike "169.254.*" } | Select-Object -First 1).IPAddress
|
||||||
$latencyMs = [math]::Round($stopwatch.ElapsedMilliseconds)
|
$externalIP = ($wc.DownloadString("https://api.ipify.org")).Trim()
|
||||||
Write-Host "Latency: $latencyMs ms" -ForegroundColor Yellow
|
Write-Host "Internal IP: $internalIP" -ForegroundColor Yellow
|
||||||
|
Write-Host "External IP: $externalIP" -ForegroundColor Yellow
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Latency probe failed: $_"
|
Write-Warning "Failed to resolve IP addresses: $_"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2. Download Test
|
# 1. Download Test
|
||||||
$downBytes = $DownloadMB * 1MB
|
$downBytes = $DownloadMB * 1MB
|
||||||
Write-Host "Testing Download ($DownloadMB MB payload)..." -NoNewline
|
Write-Host "Testing Download ($DownloadMB MB payload)..." -NoNewline
|
||||||
$stopwatch.Restart()
|
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
||||||
try {
|
try {
|
||||||
$downData = $wc.DownloadData("https://speed.cloudflare.com/__down?bytes=$downBytes")
|
$downData = $wc.DownloadData("https://speed.cloudflare.com/__down?bytes=$downBytes")
|
||||||
$stopwatch.Stop()
|
$stopwatch.Stop()
|
||||||
@@ -34,7 +35,7 @@ try {
|
|||||||
Write-Warning "`nDownload failed: $_"
|
Write-Warning "`nDownload failed: $_"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 3. Upload Test
|
# 2. Upload Test
|
||||||
$upBytes = New-Object byte[] ($UploadMB * 1MB)
|
$upBytes = New-Object byte[] ($UploadMB * 1MB)
|
||||||
(New-Object System.Random).NextBytes($upBytes)
|
(New-Object System.Random).NextBytes($upBytes)
|
||||||
Write-Host "Testing Upload ($UploadMB MB payload)..." -NoNewline
|
Write-Host "Testing Upload ($UploadMB MB payload)..." -NoNewline
|
||||||
|
|||||||
Reference in new issue
Block a user