oh-my-posh: Version 3 slower than Version 2

Prerequisites

  • I have read and understand the CONTRIBUTING guide
  • I looked for duplicate issues before submitting this one

Description

Version 3 is slower than version 2

Environment

  • Oh my Posh version: 3.132.0
  • Theme: slim
  • Operating System: Windows 10
  • Shell: pwsh 7.1.3
  • Terminal: Windows Terminal 1.6.10571.0

Steps to Reproduce

  1. Install oh-my-posh through scoop
  2. Disable Antivirus
  3. Open Windows Terminal
  4. execute pwsh -noprofile to be sure no other module interfer
  5. execute Invoke-Expression (oh-my-posh --init --shell pwsh --config "$(scoop prefix oh-my-posh3)/themes/slim.omp.json")

Expected behavior: Same execution time of version 2

Actual behavior: Slower that version 2

Notes

  • I disabled antivirus (Kaspersky)
  • I launched pwsh with -noprofile flag
  • I attached two small video
  • I have also tried to install oh-my-posh 3 through Install-Module with no luck

I used Measure-Command to oh-my-posh command, below the result

massimo@JUPITER ❯ Measure-Command { oh-my-posh }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 133
Ticks             : 1331365
TotalDays         : 1,54093171296296E-06
TotalHours        : 3,69823611111111E-05
TotalMinutes      : 0,00221894166666667
TotalSeconds      : 0,1331365
TotalMilliseconds : 133,1365

Version 2

https://user-images.githubusercontent.com/4323707/113514502-541c9580-956f-11eb-83db-b6fda5c955ee.mp4

Version 3

https://user-images.githubusercontent.com/4323707/113514530-71e9fa80-956f-11eb-8428-22b1bcc4be37.mp4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@TravisTX Do you think merging the PR anyway? I think is a good option.

You’re right I found the issue on omp.ps1 I have the Az module and two Azure Subscriptions, every time the init tries to set the $env variables, I added the if before and now run smoothly.

I don’t know where you use the Az $env variables, the below code fixes the problem and rise another: if I change the Azure Subscription? (I have two…)


    # $env:AZ_SUBSCRIPTION_NAME = $null
    # $env:AZ_SUBSCRIPTION_ID = $null

    if ($null -eq $env:AZ_SUBSCRIPTION_NAME -and $null -eq $env:AZ_SUBSCRIPTION_ID) {

        if (Get-Module -ListAvailable -Name "Az.Accounts") {
            try {
                $subscription = Get-AzContext | Select-Object -ExpandProperty "Subscription" | Select-Object "Name", "Id"
                if ($null -ne $subscription) {
                    $env:AZ_SUBSCRIPTION_NAME = $subscription.Name
                    $env:AZ_SUBSCRIPTION_ID = $subscription.Id
                }
            }
            catch {}
        }

    }