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

标签 powershell curl response-time

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

相关文章:

php - cURL connect() 超时

node.js - Node 中使用 SSL 的 SOAP 请求

ASP.NET 应用程序和 CPU 使用率

performance - 打字时的平均按键间时间

启用apache响应时间日志指令的性能影响

powershell - 需要运行 PowerShell 脚本的 Azure 云服务启动任务

sql-server - 将数组中的 PowerShell 值插入到 SQL Server 表中

c# - 如何从 C# 中的 powershell 类捕获完整的调用文本

powershell - 为什么我的局部变量为null?

linux - 在 Shell 脚本中根据 curl 输出分配变量