gpt4 book ai didi

powershell - 使用类似于curl的Invoke-WebRequest测量响应时间

转载 作者:行者123 更新时间:2023-12-01 18:00:07 32 4
gpt4 key购买 nike

我有一个 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com