Skip to content

Instantly share code, notes, and snippets.

@Yousha
Created April 30, 2025 07:51
Show Gist options
  • Save Yousha/6b5e14f59c34c17fdc19c31e6c9d07ee to your computer and use it in GitHub Desktop.
Save Yousha/6b5e14f59c34c17fdc19c31e6c9d07ee to your computer and use it in GitHub Desktop.
Tests and compares the speed of popular free/public DNS servers by measuring their response times.
@echo off
setlocal enabledelayedexpansion
REM Configure test parameters
set TEST_DOMAIN=example.com
set TRIES=5
echo Starting DNS Benchmarking... %TEST_DOMAIN%
echo.
for %%d in (
"Cloudflare,1.1.1.1"
"Google DNS,8.8.8.8"
"Google DNS2,8.8.4.4"
"Quad9,9.9.9.9"
"OpenDNS,208.67.222.222"
"CleanBrowsing,185.228.168.9"
"AdGuard DNS,94.140.14.14"
) do (
set "dns=%%~d"
for /f "tokens=1,2 delims=," %%a in ("!dns!") do (
set "provider=%%a"
set "ip=%%b"
echo Testing [%%a] at %%b...
set total=0
for /l %%i in (1,1,%TRIES%) do (
REM Use PowerShell to measure DNS query time
for /f %%t in ('powershell -command "$sw=[System.Diagnostics.Stopwatch]::StartNew(); Resolve-DnsName -Server %%b -Name %TEST_DOMAIN% -QuickTimeout -ErrorAction SilentlyContinue >null 2>&1; $sw.ElapsedMilliseconds"') do (
set time=%%t
echo Try %%i: !time! ms
set /a "total+=!time!"
)
)
set /a "average=total/%TRIES%"
echo.
echo === Average for %%a: !average! ms ===
echo.
)
)
echo Benchmarking complete. Press any key to exit.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment