Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of UseConsistentIndentation -> 35% speedup for formatter #1458

Conversation

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 22, 2020

PR Summary

Speedup is relative to the speed BEFORE my recent 2 PRs so that one sees the impact relative to those improvments (therefore the actual speedup relative to master would actually be higher). Speed is for a call of Invoke-Formatter with the default settings of the VS-Code extension.
Because the rule already loops through all tokens, there was a line that did a search through all tokens and the list of tokens can be quite long for big scripts.
First improvement would've been to create a list just consisting of pipeline tokens but even then I still saw some overhead just because it had to loop the whole list again. Therefore I optimized it further to just walk back on the current line, which is the only line of interest.
If we take this improvement and the previous 2 PRs together, then the formatter is nearly 3 times faster in total.

PR Checklist

Christoph Bergmeister added 3 commits Apr 20, 2020
Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
Co-Authored-By: Robert Holt <rjmholt@gmail.com>
@bergmeister bergmeister merged commit 5f30746 into PowerShell:master Apr 24, 2020
12 checks passed
12 checks passed
PSScriptAnalyzer-CI Build #20200422.3 succeeded
Details
PSScriptAnalyzer-CI (Build Full_Build) Build Full_Build succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_16_04) Test Ubuntu_16_04 succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_18_04) Test Ubuntu_18_04 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_5_1) Test Windows_Server2016_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_Core) Test Windows_Server2016_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_5_1) Test Windows_Server2019_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_Core) Test Windows_Server2019_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_14_Mojave) Test macOS_10_14_Mojave succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_15_Catalina) Test macOS_10_15_Catalina succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.