如何分析Powershell的启动时间?
启动我的powershell大约需要3秒,所以我想减少它。 我如何知道哪个流程会损害powershell的启动性能?如何分析Powershell的启动时间?,powershell,Powershell,启动我的powershell大约需要3秒,所以我想减少它。 我如何知道哪个流程会损害powershell的启动性能? 我想使用这样的工具。设置PSDebug方法:要快速查看您的配置文件是否慢,您可以添加 Set-PSDebug -Trace 1 到您的个人资料的顶部。然后,您将能够实时观察正在执行的各个行。将Set PSDebug-Trace 0添加到配置文件的底部以将其关闭 测量多个$PROFILE文件:要测量当前$PROFILE中自动包含的不同配置文件: $PROFILE | gm -Ty
我想使用这样的工具。设置PSDebug方法:要快速查看您的配置文件是否慢,您可以添加
Set-PSDebug -Trace 1
到您的个人资料的顶部。然后,您将能够实时观察正在执行的各个行。将Set PSDebug-Trace 0
添加到配置文件的底部以将其关闭
测量多个$PROFILE文件:要测量当前$PROFILE中自动包含的不同配置文件:
$PROFILE | gm -Type NoteProperty | % {($path=$PROFILE.($_.Name)); Measure-Command{&{. $path}}}
配置文件中的测量命令:您还可以通过编辑配置文件文件,将单个命令或整个配置文件包装到测量命令中。例如,要报告配置文件的执行时间,请执行以下操作:
$executionTime = Measure-Command `
{
# Your profile commands here
}
# $PSCommandPath is an automatic variable containing the path and file name of
# the script being run.
Write-Host "$PSCommandPath execution time: $executionTime"
这可能是你的个人资料。尝试在您的整个配置文件上运行Measure命令
。@Drew谢谢!我编写了$profile.psobject.properties |其中{$\uu-is[psnoteproperty]}| foreach{echo$\uu0.value;Measure命令{.$\u0.value}