启动我的powershell大约需要3秒,所以我想减少它。如何知道哪个进程会损害powershell的启动性能?我想使用像vim profiling这样的工具。
发布于 2021-06-02 00:51:10
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"
https://stackoverflow.com/questions/55388349
复制相似问题