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

Formatter Indentation and Delimiter Logic #1289

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

ScottCarda-MS
Copy link
Contributor

@ScottCarda-MS ScottCarda-MS commented Mar 21, 2024

Added some state to the formatter for the purposes of better handling of delimiters, i.e. [], (), {}, and type parameter list delimiters <>. The formatting of delimited blocks will be determined by whether there is a newline in the whitespace following the open delimiter.

  • If there is a newline, then the indentation is increased for the length of the block, and separators, i.e. ',' and ';', require newlines after them, with the closing delimiter having a newline in front of it.
  • If there are no newlines, then delimiters have no spacing after the opening and before the closing delimiters, except the brace delimiters which have a singe space instead, and separators require a single space after them.

Copy link

Benchmark for 5a0761d

Click to view benchmark
Test Base PR %
Array append evaluation 339.4±2.11µs 332.4±3.48µs -2.06%
Array literal evaluation 173.2±0.83µs 193.2±7.58µs +11.55%
Array update evaluation 423.2±1.99µs 416.4±2.38µs -1.61%
Deutsch-Jozsa evaluation 5.1±0.06ms 5.0±0.06ms -1.96%
Large file parity evaluation 33.5±0.06ms 33.6±0.26ms +0.30%
Large input file 30.8±1.13ms 30.6±1.17ms -0.65%
Large nested iteration 33.5±0.32ms 33.1±0.21ms -1.19%
Standard library 16.8±0.55ms 16.8±0.49ms 0.00%
Teleport evaluation 70.1±1.24µs 69.6±1.06µs -0.71%

@ScottCarda-MS ScottCarda-MS marked this pull request as ready for review March 21, 2024 17:18
@ScottCarda-MS ScottCarda-MS changed the title Formatter Indentation Logic Formatter Indentation and Delimiter Logic Mar 21, 2024
@ScottCarda-MS
Copy link
Contributor Author

I've run this version of the formatter against the samples and library files to test that nothing unreasonable or unexpected occurs. I don't want to add the updated samples/libraries to this PR though, as I think that would be better for a future PR where I could include running the formatter automatically in the build pipeline.

Copy link

Benchmark for aa9f996

Click to view benchmark
Test Base PR %
Array append evaluation 339.2±2.35µs 335.7±9.04µs -1.03%
Array literal evaluation 176.9±2.87µs 176.4±0.99µs -0.28%
Array update evaluation 417.9±1.40µs 417.5±2.59µs -0.10%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.3±0.15ms +1.92%
Large file parity evaluation 33.7±0.25ms 33.7±0.09ms 0.00%
Large input file 31.7±1.20ms 31.6±1.41ms -0.32%
Large nested iteration 32.9±0.19ms 33.0±1.26ms +0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1564.0±91.53µs 1557.3±127.84µs -0.43%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.11ms 7.8±0.09ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1477.5±110.05µs 1489.0±92.08µs +0.78%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 25.9±0.17ms 25.7±0.18ms -0.77%
Standard library 17.1±0.89ms 17.2±0.66ms +0.58%
Teleport evaluation 82.5±4.74µs 82.5±5.03µs 0.00%

Copy link

Benchmark for 5c3ee78

Click to view benchmark
Test Base PR %
Array append evaluation 330.3±3.44µs 332.8±2.78µs +0.76%
Array literal evaluation 196.1±2.33µs 178.0±12.46µs -9.23%
Array update evaluation 415.3±3.11µs 417.7±2.68µs +0.58%
Deutsch-Jozsa evaluation 5.3±0.04ms 5.3±0.16ms 0.00%
Large file parity evaluation 33.7±0.08ms 33.7±0.08ms 0.00%
Large input file 30.6±2.08ms 30.1±2.21ms -1.63%
Large nested iteration 32.3±0.67ms 33.1±0.86ms +2.48%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1572.2±84.87µs 1529.7±57.28µs -2.70%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.8±0.31ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1471.8±66.84µs 1495.3±87.36µs +1.60%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 25.8±0.47ms 25.9±0.89ms +0.39%
Standard library 17.5±0.69ms 16.8±0.22ms -4.00%
Teleport evaluation 81.9±4.45µs 81.4±4.59µs -0.61%

@ScottCarda-MS ScottCarda-MS mentioned this pull request Mar 21, 2024
@ScottCarda-MS ScottCarda-MS added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit 7944a11 Mar 21, 2024
16 checks passed
@ScottCarda-MS ScottCarda-MS deleted the sccarda/FormatterIndentation branch March 21, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants