Comments (2)
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.
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)
- VSCode shell integration disables posh-git prompt HOT 2
- Powershell 7.3.0 does not show posh-git status bar HOT 7
- Set back to default
- Tab competition: tab vs right arrow HOT 5
- Bring back Get-GitBranch HOT 2
- Suggestion: Implement a PSReadLine completion provider
- git ls-remote won't prompt
- Posh Git Module Gets Blocked by Windows Action Guard HOT 7
- Prompt not appearing. Cmder/ConEmu, Windows 11 arm64 on M1 MacBook Pro under UTM. HOT 7
- Intellisense works on commands that don't exist
- Error when pushing to Bitbucket server HOT 2
- posh-git doesn't work with vscode integrated terminal HOT 5
- posh-git: The term 'posh-git' is not recognized as a name of a cmdlet, function, script file, or executable program. HOT 1
- Tests break when run under the pwsh 7.3
- Importing posh-git shows empty prompt
- Request: Add -NoANSI option to all Write-commands
- Install fails while retrieving member "TryParse" as it violates the constraint of type 'T1' HOT 3
- posh-git is slow when navigating inside a Git LFS-enabled repository containing multiple gigabyte-sized files.
- $GitPromptSettings.UntrackedFilesMode="Defaul" doesn't respect git config for untracked files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from posh-git.