JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
16.79k stars 2.35k forks source link

performance issue on the latest version #1277

Closed ZhangAustin closed 2 years ago

ZhangAustin commented 2 years ago

Code of Conduct

What happened?

delay in showing the prompt between powershell commands.

❯❯ Measure-Command {oh-my-posh.exe --shell pwsh --config C:\Users\xxx\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json}

Days : 0 Hours : 0 Minutes : 0 Seconds : 1 Milliseconds : 210 Ticks : 12101542 TotalDays : 1.40064143518519E-05 TotalHours : 0.000336153944444444 TotalMinutes : 0.0201692366666667 TotalSeconds : 1.2101542 TotalMilliseconds : 1210.1542

❯❯ Measure-Command {oh-my-posh.exe --version}

Days : 0 Hours : 0 Minutes : 0 Seconds : 1 Milliseconds : 239 Ticks : 12394718 TotalDays : 1.43457384259259E-05 TotalHours : 0.000344297722222222 TotalMinutes : 0.0206578633333333 TotalSeconds : 1.2394718 TotalMilliseconds : 1239.4718

strangely, the following only show 1ms delays.

❯❯ oh-my-posh.exe --shell pwsh --config C:\Users\xxx\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json --debug

Version: 6.8.0

Segments:

ConsoleTitle(true) - 0 ms - pwsh in ~ os(true) - 0 ms -    path(true) - 0 ms -   ~  python(true) - 0 ms -   base  poshgit(false) - 0 ms - root(false) - 0 ms - executiontime(true) - 0 ms -  羽0ms⠀ exit(true) - 0 ms -    shell(true) - 0 ms -   pwsh  time(true) - 0 ms -  13:02:56  exit(true) - 0 ms - ❯❯

Run duration: 1.0125ms

--tried to disable other lines in the $PROFILE got no difference. only remove the oh-my-posh from $PROFILE can speed up. the full $PROFILE is like this:

  oh-my-posh --init --shell pwsh --config C:\Users\xxx\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json | Invoke-Expression
  Import-Module -Name Terminal-Icons
  $env:POSH_GIT_ENABLED = $true
  $env:AZ_ENABLED=$false      
  New-Alias open ii      
  Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete      
  Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
  Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

Theme

{
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "os",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#c386f1",
          "leading_diamond": "",
          "trailing_diamond": "\uE0B0",
          "properties": {
            "postfix": " ",
            "display_host": false
          }
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#ff479c",
          "properties": {
            "prefix": "   ",
            "home_icon": "~",            
            "style": "full",
            "mixed_threshold": 10,
            "max_depth": 10
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#111111",
          "background": "#FFDE57",
          "properties": {
            "prefix": " \uE235 ",
            "display_version": false,
            "display_mode": "context",
            "display_virtual_env": true
          }
        },
    {
      "type": "poshgit",
      "style": "powerline",
      "powerline_symbol": "\uE0B0",
      "foreground": "#ffffff",
      "background": "#0077c2"
    },
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#111111",
          "background": "#ffff66",
          "properties": {
            "root_icon": ""
          }
        },
        {
          "type": "executiontime",
          "style": "plain",
          "foreground": "#ffffff",
          "background": "#83769c",
          "leading_diamond": "",
          "trailing_diamond": "",
          "properties": {
            "always_enabled": true,
            "prefix": "<transparent>\uE0B0</> \ufa1e",
            "postfix": "\u2800"
          }
        },
        {
          "type": "exit",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#2e9599",
          "leading_diamond": "",
          "trailing_diamond": "",
          "properties": {
            "display_exit_code": false,
            "always_enabled": true,
            "error_color": "#f1184c",
            "color_background": true,
            "prefix": "<#83769c>\uE0B0</> "
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "shell",
          "style": "plain",
          "foreground": "#ffffff",
          "background": "#0077c2",
          "properties": {
            "prefix": "<#0077c2,transparent>\uE0B6</>  ",
            "postfix": " <transparent,#0077c2>\uE0B2</>"
          }
        },  
        {
          "type": "time",
          "style": "diamond",
          "invert_powerline": true,
          "leading_diamond": "\uE0B2",
          "trailing_diamond": "\uE0B4",
          "background": "#2e9599",
          "foreground": "#111111"
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "type": "exit",
          "style": "plain",
          "foreground": "#B48EAD",
          "properties": {
            "prefix": "<#C591E8>\u276F</><#69FF94>\u276F</>",
            "display_exit_code": false,
            "error_color": "#BF616A",
            "always_enabled": true
          }
        }
      ]
    }
  ],  
  "final_space": true,
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{ .Shell }} in {{ .Folder }}"
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

❯❯  Write-PoshDebug

Version: 6.8.0

Segments:

ConsoleTitle(true)   -   0 ms - powershell in ~
os(true)             -   0 ms -   
path(true)           -   0 ms -    ~ 
python(true)         -   0 ms -   base 
poshgit(false)       -   0 ms -
root(false)          -   0 ms -
executiontime(true)  -   0 ms -  羽9.001s⠀
exit(true)           -   0 ms -   
shell(true)          -   0 ms -   powershell 
time(true)           -   0 ms -  13:07:23 
exit(true)           -   0 ms - ❯❯

Run duration: 506.9µs

Logs:

2021/11/21 13:07:23 debug: getenv
C:\Users\zhang\AppData\Local
2021/11/21 13:07:23 getenv duration: 0s, args: LOCALAPPDATA
2021/11/21 13:07:23 getCachePath duration: 0s, args:
2021/11/21 13:07:23 getArgs duration: 0s, args:
2021/11/21 13:07:23 getArgs duration: 0s, args:
2021/11/21 13:07:23 getShellName duration: 6.104ms, args:
2021/11/21 13:07:23 isRunningAsRoot duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getShellName duration: 0s, args:
2021/11/21 13:07:23 getCurrentUser duration: 0s, args:
2021/11/21 13:07:23 getHostName duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getRuntimeGOOS duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getArgs duration: 0s, args:
2021/11/21 13:07:23 getRuntimeGOOS duration: 0s, args:
2021/11/21 13:07:23 getRuntimeGOOS duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getRuntimeGOOS duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 debug: getenv

2021/11/21 13:07:23 getenv duration: 0s, args: VIRTUAL_ENV
2021/11/21 13:07:23 debug: getenv

2021/11/21 13:07:23 getenv duration: 0s, args: CONDA_ENV_PATH
2021/11/21 13:07:23 debug: getenv
base
2021/11/21 13:07:23 getenv duration: 0s, args: CONDA_DEFAULT_ENV
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 506.9µs, args: *.py
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 0s, args: *.ipynb
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 0s, args: pyproject.toml
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 0s, args: venv.bak
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 0s, args: venv
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getPathSeperator duration: 0s, args:
2021/11/21 13:07:23 hasFiles duration: 0s, args: .venv
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 debug: getenv

2021/11/21 13:07:23 getenv duration: 0s, args: POSH_GIT_STATUS
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 isRunningAsRoot duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 executionTime duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 lastErrorCode duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getShellName duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 getcwd duration: 0s, args:
2021/11/21 13:07:23 lastErrorCode duration: 0s, args:
ZhangAustin commented 2 years ago

sorry, I think I found the reason. It was the antivirus software that caused the delay --- not sure what the hell it did to oh-my-posh though... but when I disable the antivirus, everything is blazing fast .

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.