* Use destructuring for readability and optimzations at for loop length property
* Destructure variables for easy maintainability of code
* PR review fix
* refactor: fix linting
* Use destructures and refactor code for better readability
* Remove merge conflict line
* lint before commit
* Use destructuring for readability and optimzations at for loop length property
* Destructure variables for easy maintainability of code
* PR review fix
* refactor: fix linting
In addition to a tiny performance improvement outlined below,
the CPU profile of traverseDoc is now more readable.
Also anonymous arrow functions changed to named regular functions
so that they are properly displayed in the CPU profile,
and moved to outer scope where there's no closure
so that they aren't re-created (this change's performance is dependent
on JS engine implementation and optimization details).
Before (profile):
```
7129.9 ms 5.43 % 13349.9 ms 10.18 % traverseDocRec
7067.4 ms 5.39 % 11285.5 ms 8.60 % traverseDocRec
31.5 ms 0.02 % 1031.9 ms 0.79 % traverseDoc
23.6 ms 0.02 % 12313.4 ms 9.39 % traverseDoc
2.6 ms 0.00 % 0.3 ms 0.00 % (anonymous)
1.7 ms 0.00 % 1.7 ms 0.00 % call
1.6 ms 0.00 % 1.6 ms 0.00 % call
0.5 ms 0.00 % 0.5 ms 0.00 % conditionalGroup
0.4 ms 0.00 % 0.4 ms 0.00 % printDocToString$1
0.1 ms 0.00 % 0.1 ms 0.00 % printGenerically
0.1 ms 0.00 % 0.1 ms 0.00 % t
0.1 ms 0.00 % 0.1 ms 0.00 % ifBreak
0.1 ms 0.00 % 0.1 ms 0.00 % (anonymous)
0 ms 0 % 0.1 ms 0.00 % forEach
```
After (profile):
```
6937.9 ms 5.37 % 12872.5 ms 9.97 % traverseDoc
5944.0 ms 4.60 % 11047.3 ms 8.55 % propagateBreaks
735.7 ms 0.57 % 1358.3 ms 1.05 % findInDoc
257.9 ms 0.20 % 466.7 ms 0.36 % findInDoc
0.1 ms 0.00 % 0.1 ms 0.00 % has
0.1 ms 0.00 % 0.1 ms 0.00 % printArgumentsList
```
Before (performance):
```
cat ../LspLanguageService.js | NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --stdin-filepath LspLanguageService.js --loglevel debug --debug-repeat 1000 > /dev/null
Debugger listening on ws://127.0.0.1:9229/4b52c027-ef62-49d6-8770-179e805a0f43
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
[debug] normalized argv: {"color":true,"editorconfig":true,"stdin-filepath":"LspLanguageService.js","loglevel":"debug","debug-repeat":1000,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","config-precedence":"cli-override","_":[]}
[debug] resolve config from '/Users/ivanbabak/_sompylasar/_github/prettier-2/LspLanguageService.js'
[debug] loaded options `null`
[debug] applied config-precedence (cli-override): {"filepath":"LspLanguageService.js"}
[debug] '--debug-repeat' option found, running formatWithCursor 1000 times.
[debug] '--debug-repeat' measurements for formatWithCursor: {
[debug] "repeat": 1000,
[debug] "hz": 7.774598830700336,
[debug] "ms": 128.624
[debug] }
```
After (performance):
```
cat ../LspLanguageService.js | NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --stdin-filepath LspLanguageService.js --loglevel debug --debug-repeat 1000 > /dev/null
Debugger listening on ws://127.0.0.1:9229/aa76e134-a68c-44ed-89a8-efb68bc46baa
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
[debug] normalized argv: {"color":true,"editorconfig":true,"stdin-filepath":"LspLanguageService.js","loglevel":"debug","debug-repeat":1000,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","config-precedence":"cli-override","_":[]}
[debug] resolve config from '/Users/ivanbabak/_sompylasar/_github/prettier/LspLanguageService.js'
[debug] loaded options `null`
[debug] applied config-precedence (cli-override): {"filepath":"LspLanguageService.js"}
[debug] '--debug-repeat' option found, running formatWithCursor 1000 times.
[debug] '--debug-repeat' measurements for formatWithCursor: {
[debug] "repeat": 1000,
[debug] "hz": 7.888114977163907,
[debug] "ms": 126.773
[debug] }
```
* Report test summaries to CircleCI
* Don’t run jest-junit on Node <6
(it uses default function parameters)
* Address @lydell’s comment
* Use @duailibe’s suggestion
* 🔥 `jest-junit` key in production package.json
* Move config to jest.config.js
* chore: upgrade Jest
* chore: update snapshots
* chore: lock down babel dependency using invalid syntax
* 2 args to test.skip
* use jest 22 for now
* Revert "2 args to test.skip"
This reverts commit 691fdc3f99e320f2303958f2b503f7b4c93fa455.
* remove snapshot name from matcher
* fix standalone tests skips
- `--debug-benchmark` uses `benchmark` module to produce statistically significant time measurements.
- `--debug-repeat` uses a naive loop and measures just the average run time, but useful for profiling to highlight hot functions.
I had this lying in my tree when I looked at maybe upgrading Jest. So why not open up a PR with it 🙂
This is `yarn-tools fix-duplicates` followed by `yarn`.
https://www.npmjs.com/package/yarn-tools
* Hande JSX whitespace separately from fbt whitespace
* Extra test cases
* Further tweak to JSX handling
* Possible improvement of single character text
* More tests
* Pull out separator code
* More tests for fbt