Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measure response time using Invoke-WebRequest similar to curl

I have a curl command which response time by breaking it by each action in invoking a service.

curl -w "@sample.txt" -o /dev/null someservice-call

I want to measure the response time in a similar way using PowerShell's built-in Invoke-WebRequest call. So far I am able to get total response time using Measure-Command. Can someone please help me with this?

Content of sample.txt used in curl:

time_namelookup:  %{time_namelookup}\n               
time_connect:  %{time_connect}\n            
time_appconnect:  %{time_appconnect}\n           
time_pretransfer:  %{time_pretransfer}\n              
time_redirect:  %{time_redirect}\n         
time_starttransfer:  %{time_starttransfer}\n                            
----------\n          
time_total:  %{time_total}\n
like image 324
Rock Avatar asked Jul 05 '18 19:07

Rock


1 Answers

time in milliseconds:

$url = "google.com"
(Measure-Command -Expression { $site = Invoke-WebRequest -Uri $url -UseBasicParsing }).Milliseconds
like image 94
Falco Alexander Avatar answered Sep 20 '22 10:09

Falco Alexander