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

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

Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
Rules/UseConsistentIndentation.cs Outdated Show resolved Hide resolved
@bergmeister bergmeister merged commit 5f30746 into PowerShell:master Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants