我有一个 curl
命令,通过调用服务时的每个操作来中断它的响应时间。
curl -w "@sample.txt" -o /dev/null someservice-call
我想使用 PowerShell 的内置 Invoke-WebRequest
调用以类似的方式测量响应时间。到目前为止,我可以使用 Measure-Command 获得总响应时间。有人可以帮我解决这个问题吗?
curl
中使用的sample.txt
内容:
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
最佳答案
时间(以毫秒为单位):
$url = "google.com"
(Measure-Command -Expression { $site = Invoke-WebRequest -Uri $url -UseBasicParsing }).Milliseconds
关于powershell - 使用类似于curl的Invoke-WebRequest测量响应时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51198517/