启动powershell大约需要3秒钟,所以我想减少它。 我怎么知道哪个进程会损害Powershell的启动性能? 我想使用vim profiling之类的工具。
答案 0 :(得分:0)
Set-PSDebug 方法:要快速查看您的配置文件是否缓慢,您可以添加
Set-PSDebug -Trace 1
到您个人资料的顶部。然后,您将能够实时查看正在执行的各个行。将 Set-PSDebug -Trace 0
添加到您的个人资料底部以将其关闭。
测量您的多个 $PROFILE 文件:要测量您当前 $PROFILE 中自动包含的不同配置文件:
$PROFILE | gm -Type NoteProperty | % {($path=$PROFILE.($_.Name)); Measure-Command{&{. $path}}}
您的配置文件中的测量命令:您还可以通过编辑您的配置文件将单个命令或您的整个配置文件包含在 Measure-Command
中。例如,要报告您的配置文件的执行时间:
$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"