Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Log website response times with cURL in windows

This code snippet should be saved as a batch file and run in Windows. It can be set up as a scheduled task to log response times at a fixed interval. It takes one argument, the URL, which should be enclosed in quotes or Windows will barf on URLs with = (equals) signs in. If you don't supply any arguments, you will be prompted. Binary versions of curl are available via google.

If you have ISA:
REM measure response times for a site:
@echo off
IF a%1 == a (
  SET /P varHost=Enter the address, e.g. http://google.com: 
) ELSE (
  SET varHost=%1
)
SET startTime=%date% %time%
curl.exe --proxy-ntlm --proxy yourISAproxy:8080 --proxy-user username:password -s %varHost% > fulloutput.txt
echo %startTime%,%date% %time%,%varHost% >> respTimeLog.txt


If you have no proxy:
REM measure response times for a site:
@echo off
IF a%1 == a (
  SET /P varHost=Enter the address, e.g. http://google.com: 
) ELSE (
  SET varHost=%1
)
SET startTime=%date% %time%
curl -s %varHost% > fulloutput.txt
echo %startTime%,%date% %time%,%varHost% >> respTimeLog.txt

cURL Response Times

Determine response times of a URL with cURL.


echo "`curl -s -o /dev/null -w '%{time_starttransfer}-%{time_pretransfer}' http://www.domain.com/`"|bc

curl -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null -s http://www.domain.com/