diff --git a/test/perf/debug.html b/benchmark/index.html similarity index 84% rename from test/perf/debug.html rename to benchmark/index.html index 54f9cf07f2aed8..0136af6ac6e532 100644 --- a/test/perf/debug.html +++ b/benchmark/index.html @@ -8,6 +8,6 @@
- + diff --git a/benchmark/index.js b/benchmark/index.js new file mode 100644 index 00000000000000..0e33ac23fb57f5 --- /dev/null +++ b/benchmark/index.js @@ -0,0 +1,13 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; + +// Get all the scenarios +const requirePerfScenarios = require.context('./scenarios', true, /(js|ts|tsx)$/); + +const rootEl = document.getElementById('root'); + +const scenarioSuitePath = window.location.search.replace('?', ''); + +const Component = requirePerfScenarios(scenarioSuitePath).default; + +ReactDOM.render(, rootEl); diff --git a/test/perf/tests/box-emotion/index.js b/benchmark/scenarios/box-emotion/index.js similarity index 100% rename from test/perf/tests/box-emotion/index.js rename to benchmark/scenarios/box-emotion/index.js diff --git a/test/perf/tests/box-material-ui-styles/index.js b/benchmark/scenarios/box-material-ui-styles/index.js similarity index 100% rename from test/perf/tests/box-material-ui-styles/index.js rename to benchmark/scenarios/box-material-ui-styles/index.js diff --git a/test/perf/tests/box-styled-components/index.js b/benchmark/scenarios/box-styled-components/index.js similarity index 100% rename from test/perf/tests/box-styled-components/index.js rename to benchmark/scenarios/box-styled-components/index.js diff --git a/test/perf/tests/material-ui-system-all-inclusive/index.js b/benchmark/scenarios/material-ui-system-all-inclusive/index.js similarity index 100% rename from test/perf/tests/material-ui-system-all-inclusive/index.js rename to benchmark/scenarios/material-ui-system-all-inclusive/index.js diff --git a/test/perf/tests/material-ui-system-colors/index.js b/benchmark/scenarios/material-ui-system-colors/index.js similarity index 100% rename from test/perf/tests/material-ui-system-colors/index.js rename to benchmark/scenarios/material-ui-system-colors/index.js diff --git a/test/perf/tests/material-ui-system-compose/index.js b/benchmark/scenarios/material-ui-system-compose/index.js similarity index 100% rename from test/perf/tests/material-ui-system-compose/index.js rename to benchmark/scenarios/material-ui-system-compose/index.js diff --git a/test/perf/tests/material-ui-system-spaces/index.js b/benchmark/scenarios/material-ui-system-spaces/index.js similarity index 100% rename from test/perf/tests/material-ui-system-spaces/index.js rename to benchmark/scenarios/material-ui-system-spaces/index.js diff --git a/test/perf/tests/naked-styled-components/index.js b/benchmark/scenarios/naked-styled-components/index.js similarity index 100% rename from test/perf/tests/naked-styled-components/index.js rename to benchmark/scenarios/naked-styled-components/index.js diff --git a/test/perf/tests/styled-components-box-material-ui-system/index.js b/benchmark/scenarios/styled-components-box-material-ui-system/index.js similarity index 100% rename from test/perf/tests/styled-components-box-material-ui-system/index.js rename to benchmark/scenarios/styled-components-box-material-ui-system/index.js diff --git a/test/perf/tests/styled-components-box-styled-system/index.js b/benchmark/scenarios/styled-components-box-styled-system/index.js similarity index 100% rename from test/perf/tests/styled-components-box-styled-system/index.js rename to benchmark/scenarios/styled-components-box-styled-system/index.js diff --git a/test/perf/tests/styled-system-colors/index.js b/benchmark/scenarios/styled-system-colors/index.js similarity index 100% rename from test/perf/tests/styled-system-colors/index.js rename to benchmark/scenarios/styled-system-colors/index.js diff --git a/test/perf/tests/styled-system-compose/index.js b/benchmark/scenarios/styled-system-compose/index.js similarity index 100% rename from test/perf/tests/styled-system-compose/index.js rename to benchmark/scenarios/styled-system-compose/index.js diff --git a/test/perf/tests/styled-system-spaces/index.js b/benchmark/scenarios/styled-system-spaces/index.js similarity index 100% rename from test/perf/tests/styled-system-spaces/index.js rename to benchmark/scenarios/styled-system-spaces/index.js diff --git a/test/perf/tests/utils/index.js b/benchmark/scenarios/utils/index.js similarity index 100% rename from test/perf/tests/utils/index.js rename to benchmark/scenarios/utils/index.js diff --git a/test/perf/webpack.config.js b/benchmark/webpack.config.js similarity index 80% rename from test/perf/webpack.config.js rename to benchmark/webpack.config.js index f95ea63d0d3ae6..8b9036f80b4898 100644 --- a/test/perf/webpack.config.js +++ b/benchmark/webpack.config.js @@ -1,13 +1,13 @@ const path = require('path'); -const webpackBaseConfig = require('../../webpackBaseConfig'); +const webpackBaseConfig = require('../webpackBaseConfig'); module.exports = { ...webpackBaseConfig, entry: path.resolve(__dirname, 'index.js'), mode: 'development', output: { - path: path.resolve(__dirname, '../../tmp'), - filename: 'tests.js', + path: path.resolve(__dirname, '../tmp'), + filename: 'benchmark.js', }, module: { ...webpackBaseConfig.module, diff --git a/package.json b/package.json index 63dbfcdf3848bd..026e61e18e3833 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "proptypes": "cross-env BABEL_ENV=test babel-node --extensions \".tsx,.ts,.js\" ./scripts/generateProptypes.ts", "deduplicate": "node scripts/deduplicate.js", "argos": "argos upload test/regressions/screenshots/chrome --token $ARGOS_TOKEN", + "benchmark": "yarn webpack --config benchmark/webpack.config.js --mode \"production\" && node scripts/benchmark.js", "build:codesandbox": "lerna run --parallel --scope \"@material-ui/*\" build", "docs:api": "rimraf ./docs/pages/api-docs && yarn docs:api:build", "docs:api:build": "cross-env BABEL_ENV=test __NEXT_EXPORT_TRAILING_SLASH=true babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/buildApi.ts ./docs/pages/api-docs ./packages/material-ui/src ./packages/material-ui-lab/src", @@ -27,7 +28,6 @@ "jsonlint": "node scripts/jsonlint.js", "lint": "eslint . --cache --report-unused-disable-directives --ext .js,.ts,.tsx", "lint:ci": "eslint . --report-unused-disable-directives --ext .js,.ts,.tsx", - "perf": "yarn webpack --config test/perf/webpack.config.js --mode \"production\" && node scripts/perf.js", "prettier": "node ./scripts/prettier.js", "prettier:all": "node ./scripts/prettier.js write", "size:snapshot": "node scripts/sizeSnapshot/create", diff --git a/scripts/perf.js b/scripts/benchmark.js similarity index 97% rename from scripts/perf.js rename to scripts/benchmark.js index 12e495e7e34379..24bea6eee845e0 100644 --- a/scripts/perf.js +++ b/scripts/benchmark.js @@ -8,7 +8,7 @@ const http = require('http'); const SERVER = 'localhost'; const PORT = 1122; -const APP = 'test/perf/debug'; +const APP = 'benchmark'; http .createServer((request, response) => { @@ -41,12 +41,12 @@ async function runMeasures(browser, testCase, times) { for (let i = 0; i < times; i += 1) { const { page, close } = await browser.openPage(`http://${SERVER}:${PORT}/${APP}?${testCase}`); - const perf = await page.evaluate(() => { + const benchmark = await page.evaluate(() => { const { loadEventEnd, navigationStart } = performance.timing; return loadEventEnd - navigationStart; }); - measures.push(perf); + measures.push(benchmark); await close(); } diff --git a/test/perf/index.js b/test/perf/index.js deleted file mode 100644 index b38f49afc19b17..00000000000000 --- a/test/perf/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; - -// Get all the tests specifically written for preventing regressions. -const requirePerfTests = require.context('./tests', true, /(js|ts|tsx)$/); - -const rootEl = document.getElementById('root'); - -// ./Button/index.js -// ./Dialog/index.js - -const testSuitePath = window.location.search.replace('?', ''); - -const Component = requirePerfTests(testSuitePath).default; - -ReactDOM.render(, rootEl);