手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell检查网站响应并计算执行时间例子
Powershell检查网站响应并计算执行时间例子
摘要:有时候你需要知道命令的执行时间,例如,你可以使用Invoke-WebReques查看网站的响应,再使用Measure-Command计算执行...

有时候你需要知道命令的执行时间,例如,你可以使用Invoke-WebReques查看网站的响应,再使用Measure-Command计算执行的时间。

复制代码 代码如下:

$url = 'http://www.powershell.com'

# track execution time:

$timeTaken = Measure-Command -Expression {

$site = Invoke-WebRequest -Uri $url

}

$milliseconds = $timeTaken.TotalMilliseconds

$milliseconds = [Math]::Round($milliseconds, 1)

"This took $milliseconds ms to execute"

其中返回的时间间隔属性中包涵了一个“TotalMilliseconds”属性;如果有必须要你也可以使用Round()函数将其化整,这个例子中我们将保留小数点后第一位。

【Powershell检查网站响应并计算执行时间例子】相关文章:

PowerShell中计算时间差的方法

Powershell访问SQL Server数据库代码实例

Python中调用PowerShell、远程执行bat文件实例

Windows Powershell 执行文件和脚本

Powershell获取图片名字、文件夹及拍摄时间的例子

Powershell展开对象数据结构并以JSON格式输出

PowerShell计算脚本执行时间的实现方法

Powershell中打开网页实例

Powershell创建简洁的HTML报告例子

Powershell中使用WMI工具例子

精品推荐
分类导航