diff --git a/test/perf/tests/box-emotion/index.js b/test/perf/tests/box-emotion/index.js index b5212f3017d0fb..d541797ee88c72 100644 --- a/test/perf/tests/box-emotion/index.js +++ b/test/perf/tests/box-emotion/index.js @@ -1,16 +1,17 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import styledEmotion from '@emotion/styled'; import { ThemeProvider as EmotionTheme } from 'emotion-theming'; import { styleFunction } from '@material-ui/core/Box'; +import { logReactMetrics } from '../utils'; const materialSystemTheme = createMuiTheme(); const BoxEmotion = styledEmotion('div')(styleFunction); const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/box-material-ui-styles/index.js b/test/perf/tests/box-material-ui-styles/index.js index a14e4ceefcab57..f6ca96c452495a 100644 --- a/test/perf/tests/box-material-ui-styles/index.js +++ b/test/perf/tests/box-material-ui-styles/index.js @@ -1,14 +1,15 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import { ThemeProvider as StylesThemeProvider } from '@material-ui/styles'; import BoxStyles from '@material-ui/core/Box'; +import { logReactMetrics } from '../utils'; const materialSystemTheme = createMuiTheme(); const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/box-styled-components/index.js b/test/perf/tests/box-styled-components/index.js index e33a03053b5091..9038398e0cf3a8 100644 --- a/test/perf/tests/box-styled-components/index.js +++ b/test/perf/tests/box-styled-components/index.js @@ -1,16 +1,17 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import { styleFunction } from '@material-ui/core/Box'; import styledComponents, { ThemeProvider as StyledComponentsThemeProvider, } from 'styled-components'; +import { logReactMetrics } from '../utils'; const materialSystemTheme = createMuiTheme(); const BoxStyleComponents = styledComponents('div')(styleFunction); const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/naked-styled-components/index.js b/test/perf/tests/naked-styled-components/index.js index 8ddc8541a5eeeb..9d55d176d7aa2c 100644 --- a/test/perf/tests/naked-styled-components/index.js +++ b/test/perf/tests/naked-styled-components/index.js @@ -1,16 +1,17 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import { spacing } from '@material-ui/system'; import styledComponents, { ThemeProvider as StyledComponentsThemeProvider, } from 'styled-components'; +import { logReactMetrics } from '../utils'; const materialSystemTheme = createMuiTheme(); const NakedStyleComponents = styledComponents('div')(spacing); const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/styled-components-box-material-ui-system/index.js b/test/perf/tests/styled-components-box-material-ui-system/index.js index e71cf34fbe5af2..b27d43bb54a667 100644 --- a/test/perf/tests/styled-components-box-material-ui-system/index.js +++ b/test/perf/tests/styled-components-box-material-ui-system/index.js @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import styledComponents, { ThemeProvider as StyledComponentsThemeProvider, } from 'styled-components'; import { spacing, palette, typography, compose } from '@material-ui/system'; +import { logReactMetrics } from '../utils'; const materialSystem = compose(palette, spacing, typography); const materialSystemTheme = createMuiTheme(); @@ -11,7 +12,7 @@ const BoxMaterialSystem = styledComponents('div')(materialSystem); const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/styled-components-box-styled-system/index.js b/test/perf/tests/styled-components-box-styled-system/index.js index cccb3cd6590abf..4e1acc51ee0a1c 100644 --- a/test/perf/tests/styled-components-box-styled-system/index.js +++ b/test/perf/tests/styled-components-box-styled-system/index.js @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { Profiler } from 'react'; import { createMuiTheme } from '@material-ui/core/styles'; import styledComponents, { ThemeProvider as StyledComponentsThemeProvider, } from 'styled-components'; import { space, color, fontFamily, fontSize, compose } from 'styled-system'; +import { logReactMetrics } from '../utils'; const styledSystem = compose(color, space, fontFamily, fontSize); const BoxStyledSystem = styledComponents('div')(styledSystem); @@ -16,7 +17,7 @@ styledSystemTheme.fonts = styledSystemTheme.typography; const App = () => { return ( - <> + {new Array(100).fill().map(() => ( { ))} - + ); } diff --git a/test/perf/tests/utils/index.js b/test/perf/tests/utils/index.js new file mode 100644 index 00000000000000..ac65aba62a9c26 --- /dev/null +++ b/test/perf/tests/utils/index.js @@ -0,0 +1,19 @@ +export const logReactMetrics = ( + id, // the "id" prop of the Profiler tree that has just committed + phase, // either "mount" (if the tree just mounted) or "update" (if it re-rendered) + actualDuration, // time spent rendering the committed update + baseDuration, // estimated time to render the entire subtree without memoization + startTime, // when React began rendering this update + commitTime, // when React committed this update + interactions // the Set of interactions belonging to this update +) => { + console.info({ + id, + phase, + actualDuration, + baseDuration, + startTime, + commitTime, + interactions, + }); +} \ No newline at end of file diff --git a/test/perf/webpack.config.js b/test/perf/webpack.config.js index f58dbcb436e582..6e8d7820d0ff4a 100644 --- a/test/perf/webpack.config.js +++ b/test/perf/webpack.config.js @@ -21,4 +21,12 @@ module.exports = { }, ]), }, + resolve: { + ...webpackBaseConfig.resolve, + alias: { + ...webpackBaseConfig.resolve.alias, + 'react-dom$': 'react-dom/profiling', + 'scheduler/tracing': 'scheduler/tracing-profiling', + } + } };