CUPAIR

PowerShell 启动慢

  •  
  •   CUPAIR · Apr 6, 2022 · 10912 views
    This topic created in 1682 days ago, the information mentioned may be changed or developed.

    pwsh:powershell7.15; powershell: powershellv1.0,不知道啥版本,就 win11 自带的 :

    • 配置oh-my-posh+posh-git两个模块,启动速度 1000ms-1100ms
    • 把$profile内容全部注释掉,启动速度,启动速度 500ms
    • pwsh -noprofile有明显停顿感(但感觉应该没 500ms 这么夸张了)
    • powershell -noprofile几乎没有延迟

    这个延迟太高了,不知道有什么优化方法没,stackoverflow上提到.net 框架升级,感觉不怎么靠谱,因为powershell -noprofile这个指令基本没啥延迟,所以感觉应该是配置文件优化的问题,有 v 友懂如何优化吗

    23 replies  •  2024-07-20 21:08:40 +08:00
    ersic
    ersic
    Apr 6, 2022❤️4
    1
    我之前用 oh-my-posh+posh ,配置了一大堆东西,感觉是慢了,现在在用 https://github.com/starship/starship
    hope4tomorrow
    hope4tomorrow
    Apr 6, 2022
    2
    macos ,之前用 iterm2 + zsh ,用了 oh-my-zsh 和各种插件,启动 1s+,忍受不了,随即换成 wezterm, 目前丝滑到极致。。。
    Tumblr
    Tumblr
    Apr 6, 2022
    3
    这让我想到了当年比拼 Windows 开机速度的时候,这个“我开机 10 秒”,那个“我开机 8 秒”,一定要争做那个最快的男人……
    nightwitch
    nightwitch
    Apr 6, 2022
    4
    没什么优化的,powershell 就是很慢。
    如果对速度有要求建议自己写点 alias 就行了,主题之类的会很慢
    creanme
    creanme
    Apr 6, 2022
    5
    我 pwshl 冷启动花了至少 6 秒。。。。真的离谱。再次启动就快多了,估计 500 多毫秒。
    ncepuzs
    ncepuzs
    Apr 6, 2022
    6
    @ersic 同样是从 oh my posh 转向 starship prompt
    CUPAIR
    CUPAIR
    OP
    Apr 6, 2022
    7
    @ersic 换了一下,启动速度 700-800ms ,感觉延迟还是高,但 starship 默认的主题挺简洁的,好看
    tuutoo
    tuutoo
    Apr 6, 2022
    8
    我现在也在用 oh-my-posh+posh 可能电脑配置也有点关系 同样配置单位电脑要 2000ms - 4000ms 不等,家里的 400ms 左右。
    也是慢的不能忍受,看了下二楼这个好像不错,准备试一下。
    ersic
    ersic
    Apr 6, 2022
    9
    @CUPAIR 我大概也是这个延迟,感觉没法再优化了。
    h404bi
    h404bi
    Apr 6, 2022
    10
    就是很慢,我的配置文件加载基本 1500ms 以上,习惯了。
    356693212
    356693212
    Apr 6, 2022
    11
    Loading personal and system profiles took 1798ms. 你可以二分法测试。谁知道你有什么配置和插件啊。
    CokeMine
    CokeMine
    Apr 6, 2022
    12
    pwsh -noprofile 有的时候能卡到好几十秒才能加载出来(有时好几十秒,有时几秒,有时很快,5.x 7.x 版本都这样)
    加上 -noprofile 了肯定不是一些插件的问题
    网上搜了一些 用什么 ngen.exe 什么的方法都无效
    skinny
    skinny
    Apr 6, 2022❤️3
    13
    试试加两个环境变量然后重启:
    POWERSHELL_TELEMETRY_OPTOUT=1
    POWERSHELL_UPDATECHECK=Off

    再慢就没有办法了。
    ecoo
    ecoo
    Apr 6, 2022
    14
    @ncepuzs #6 我刚刚也换了,速度虽然差不多,但是真好看
    duke807
    duke807
    Apr 6, 2022
    15
    我想知道怎麼測試啓動速度,我的 xfce 桌面,ctrl + alt + t 快捷鍵打開 shell 窗口太快了,完全沒法測速度啊。。。
    Lemeng
    Lemeng
    Apr 6, 2022
    16
    习惯就好,也没啥大问题
    beetlerx
    beetlerx
    Apr 6, 2022
    17
    一直用 msys2 + hyper ( https://hyper.is/) + oh-my-zsh
    CUPAIR
    CUPAIR
    OP
    Apr 7, 2022
    18
    @skinny 速度没啥改观,这个去掉烦人的更新提示倒是很赞
    skinny
    skinny
    Apr 7, 2022
    19
    @CUPAIR 这个更新检查因为一些网络问题会严重拖慢启动速度。因为一些中文编码问题退回 5.1 了,目前还挺快的,能忍受的范围。
    lelandsu
    lelandsu
    Oct 17, 2022
    20
    是真的慢,希望谁有办法能这里回一句
    CUPAIR
    CUPAIR
    OP
    Oct 17, 2022
    21
    @lelandsu 如果装了 conda ,conda init powershell 后大概会拖慢一秒左右启动时间,可以在你 powershell 的`$profile` 同级目录下的 `profile.ps1`里注释掉启动 conda 那个语句,然后自己设个 alias ,用 conda 时手动激活
    kawaiidora
    kawaiidora
    Nov 22, 2023
    22
    装完 starship 后,载入时间在 600~700ms 之间,差强人意
    kawaiidora
    kawaiidora
    Jul 20, 2024 via Android
    23
    不带插件就很快,但凡装一个插件速度就慢下来了

    但是刚需 psreadline ,最后躺平了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2152 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 13:17 · PVG 21:17 · LAX 05:17 · JFK 08:17
    ♥ Do have faith in what you're doing.