Giter Club home page Giter Club logo

Comments (2)

domsleee avatar domsleee commented on June 12, 2024 3

I like the performance energy here, I also had a look at this

I found that a $PROFILE with a single line of Import-Module ~\git\posh-git\src\posh-git.psd1 adds 412ms to my startup time of 214ms.

❯ hyperfine --warmup 2 'pwsh -c "echo hello world"' 'pwsh -NoProfile -c "echo hello world"'
Benchmark 1: pwsh -c "echo hello world"
  Time (mean ± σ):     626.3 ms ±   3.9 ms    [User: 3.1 ms, System: 10.9 ms]
  Range (min … max):   619.2 ms … 631.8 ms    10 runs

Benchmark 2: pwsh -NoProfile -c "echo hello world"
  Time (mean ± σ):     214.5 ms ±   2.6 ms    [User: 2.4 ms, System: 6.7 ms]
  Range (min … max):   210.6 ms … 220.1 ms    13 runs

Summary
  'pwsh -NoProfile -c "echo hello world"' ran
    2.92 ± 0.04 times faster than 'pwsh -c "echo hello world"'

Using feature/profiling of posh-git and feature/human-readable-duration of PSProfiler to profile , I found some of the hotspots:

 pwsh -NoProfile {
    Import-Module ~\git\PSProfiler\src\PSProfiler.psd1
    Measure-Script -HumanReadable -Path ~\git\posh-git\src\posh-git.ps1
}
...
 1    10             42ms . $PSScriptRoot\CheckRequirements.ps1 > $null
 0    11              0ms
 1    12             34ms . $PSScriptRoot\ConsoleMode.ps1
 1    13             24ms . $PSScriptRoot\Utils.ps1
 1    14              8ms . $PSScriptRoot\AnsiUtils.ps1
 1    15              8ms . $PSScriptRoot\WindowTitle.ps1
 1    16             12ms . $PSScriptRoot\PoshGitTypes.ps1
 1    17             15ms . $PSScriptRoot\GitUtils.ps1
 1    18             65ms . $PSScriptRoot\GitPrompt.ps1
 1    19             15ms . $PSScriptRoot\GitParamTabExpansion.ps1
 1    20             63ms . $PSScriptRoot\GitTabExpansion.ps1
 1    21              5ms . $PSScriptRoot\TortoiseGit.ps1
...

By removing code that isn't related to tab completion, I could get a measured startup time of 486ms in hyperfine, which 271ms for the module, a 34% improvement (271 / 412).
If anybody is interested to try, the code is on feature/profiling of posh-git.

However, avoiding "dot-sourcing" everything related to prompt, could be problematic to integrate with "bundling everything into a single file" as proposed in #698 - but will we finalize it?

I wanted to say about this one, it would be nice if we could have a bundle just with the tab completion logic? Like we could have two bundles, one with prompt + tab completion, and the other with just tab completion, and choose which one to source based on $DisablePromptSupport or similar. Or we could split tab completion to an entirely new PSModule?

from posh-git.

DominikJaniec avatar DominikJaniec commented on June 12, 2024 1

Nice, I saw similar distribution of times related to "dot-sourcing" respective files.


In the matter of separated modules with different set of bundled code. I think, this could be a very neat option to have, e.g. posh-git and posh-git-completion, where the latest will not support prompt at all. However, I believe this would bring more burden for maintainers, and could rise possible issues with confusion of what do what, and which module who should use - but maybe this should be a way.

from posh-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.