perf(Theme): performance measures for Context usage#1106
perf(Theme): performance measures for Context usage#1106layershifter merged 19 commits intomasterfrom
Conversation
build/gulp/tasks/perf.ts
Outdated
There was a problem hiding this comment.
Breaks test runs on Windows...
Codecov Report
@@ Coverage Diff @@
## master #1106 +/- ##
=======================================
Coverage 82.38% 82.38%
=======================================
Files 733 733
Lines 8720 8720
Branches 1165 1165
=======================================
Hits 7184 7184
Misses 1521 1521
Partials 15 15Continue to review full report at Codecov.
|
Generated by 🚫 dangerJS |
806db58 to
90fab36
Compare
perf/src/index.tsx
Outdated
| matchBase: true, | ||
| }) | ||
|
|
||
| const sortObjectKeys = o => |
There was a problem hiding this comment.
I will be grad to replace this with Lodash equivalent, if you know it, please propose 😺
There was a problem hiding this comment.
I've always thought order of object keys is not guaranteed 🤔
There was a problem hiding this comment.
Current Language Spec (since ES2015) insertion order is preserved, except in the case of keys that parse as integers (eg "7" or "99"), where behavior varies between browsers. For example, Chrome/V8 does not respect insertion order when the keys are parse as numeric.
docs/src/examples/components/Box/Performance/ContextPropNesting.perf.tsx
Outdated
Show resolved
Hide resolved
Actually, there is one more API that we can use Class.contextType. It was introduced in 16.6. |
…dust-ui/react into perf/context # Conflicts: # package.json # yarn.lock
3265141 to
75265f8
Compare
build/gulp/tasks/perf.ts
Outdated
| _.round((actualValue / minValue) * 100 - 100, 2) | ||
|
|
||
| const createMarkdownTable = ( | ||
| data, |
There was a problem hiding this comment.
can we introduce type for data arg - to make it easier to reason about structure of contained data?
There was a problem hiding this comment.
renamed to normalizedMeasures and add more types 👍
yarn.lock
Outdated
| resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.3.tgz#d2d7462fcfcbe6ec0da56ad69047e47e56e7eac0" | ||
| integrity sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA== | ||
|
|
||
| react-is@^16.7.0, react-is@^16.8.6: |
There was a problem hiding this comment.
just curious if there is a real reason to have so many versions of this package in resolutions - maybe it could be possible to reduce all into one
perf/src/index.tsx
Outdated
| const [filter, setFilter] = React.useState('') | ||
|
|
||
| return ( | ||
| /* Heads up! This provider also does first run work! */ |
There was a problem hiding this comment.
lets be a bit more explicit about first run meaning. Essentially, we need to provide the implications for the perf tests first, and then elaborate on the reason for them, something like
On first run, this Provider increases measured time due to style DOM elements being rendered to the browser. Subsequent rerenders, in contrast, are not rendering these style DOM elements again.
| import Types from './Types' | ||
|
|
||
| const HeaderExamples = () => ( | ||
| const BoxExamples = () => ( |
build/webpack.config.perf.ts
Outdated
| docs: paths.base('docs'), | ||
| src: paths.packageSrc('react'), | ||
|
|
||
| // We are React in production mode with tracing. |
There was a problem hiding this comment.
nit: seems that using word is missed
perf/src/index.tsx
Outdated
| const sortObjectKeys = o => | ||
| Object.keys(o) | ||
| .sort() | ||
| .reduce((r, k) => ((r[k] = o[k]), r), {}) |
There was a problem hiding this comment.
Removed it at all, it confused two people...
yarn.lock
Outdated
| react-is "^16.8.1" | ||
|
|
||
| react-test-renderer@^16.0.0, react-test-renderer@^16.0.0-0: | ||
| react-test-renderer@^16.0.0-0: |
There was a problem hiding this comment.
same here - is there any reason for us to have these two (I mean, non-addressable reason:)
| } | ||
| const satisfiesFilter = (componentName: string, filter: string) => | ||
| minimatch(componentName, filter || '*', { | ||
| matchBase: true, |
There was a problem hiding this comment.
nit: lets be a bit more strict here: we may rename componentName with either componentExampleName or most explicit componentFilePath to better indicate the fact that this is more than just name of the component. It will make it easier to get the reason for this option from code
There was a problem hiding this comment.
componentFilePath is correct 👍
perf/src/index.html
Outdated
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <div id="control"></div> |
There was a problem hiding this comment.
lets introduce comment for the second mount point that would explain what it is used for (and, maybe we could rename it to control-tools, tools-panel or something like that)
This PR has two targets:
theme1. Use
minimatchfor--filterThis allows to get flexible filtering and run only needed examples:
yarn gulp perf --filter=*Context*Nesting*yarn gulp perf "--filter=*(ContextUse|ContextProp|ContextConsumer|ContextFelaTheme).*"2. Add progress bar for perf tests
3. Add markdown table to output
You can now just copy-paste to Github 👍
4. Run perf tests with production React
As we concentrated on production performance, with should run production React and pass
process.env.NODE_ENV = productionto get optimizations for third party libraries.5. Add
perf:debugThis will start development build of React to get measurements in flamegraph and will allow to run perf tests:
gulp perf --filter=*Context*Nesting* --times=100gulp perf "--filter=*(ContextUse|ContextProp|ContextConsumer|ContextFelaTheme|ContextClassField|ContextClassConsumer).*" --times=100