Skip to content

Commit 7f484cb

Browse files
authored
chore: cleanup benchmark scripts (#12688)
1 parent aa3692d commit 7f484cb

File tree

17 files changed

+44
-33
lines changed

17 files changed

+44
-33
lines changed

.eslintrc.cjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ module.exports = {
237237
},
238238
{
239239
files: [
240+
'e2e/**',
240241
'website/**',
242+
'**/__benchmarks__/**',
241243
'**/__tests__/**',
242-
'e2e/**',
243-
'**/pretty-format/perf/**',
244244
'packages/jest-types/**/*',
245245
'.eslintplugin/**',
246246
],
@@ -263,6 +263,7 @@ module.exports = {
263263
{
264264
files: [
265265
'scripts/*',
266+
'packages/*/__benchmarks__/test.js',
266267
'packages/jest-cli/src/init/index.ts',
267268
'packages/jest-repl/src/cli/runtime-cli.ts',
268269
],
@@ -274,14 +275,10 @@ module.exports = {
274275
files: [
275276
'e2e/**',
276277
'examples/**',
277-
'scripts/*',
278278
'website/**',
279279
'**/__mocks__/**',
280280
'**/__tests__/**',
281281
'**/__typetests__/**',
282-
'**/__performance_tests__/**',
283-
'packages/diff-sequences/perf/index.js',
284-
'packages/pretty-format/perf/test.js',
285282
],
286283
rules: {
287284
'@typescript-eslint/no-unused-vars': 'off',

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ coverage
99
/packages/*/build
1010
/packages/*/dist
1111
/packages/jest-config/src/__tests__/jest-preset.json
12-
/packages/pretty-format/perf/world.geo.json
12+
/packages/pretty-format/__benchmarks__/world.geo.json
1313

1414
# Breaks tests
1515
/e2e/coverage-handlebars/greet.hbs

jest.config.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
'**/packages/*/**/*.ts',
1616
'!**/bin/**',
1717
'!**/cli/**',
18-
'!**/perf/**',
18+
'!**/__benchmarks__/**',
1919
'!**/__mocks__/**',
2020
'!**/__tests__/**',
2121
'!**/__typetests__/**',
@@ -38,6 +38,7 @@ export default {
3838
snapshotSerializers: [require.resolve('pretty-format/ConvertAnsi')],
3939
testPathIgnorePatterns: [
4040
'/__arbitraries__/',
41+
'/__benchmarks__/',
4142
'/__typetests__/',
4243
'/node_modules/',
4344
'/examples/',
@@ -64,8 +65,6 @@ export default {
6465
'/packages/jest-snapshot/src/__tests__/plugins',
6566
'/packages/jest-snapshot/src/__tests__/fixtures/',
6667
'/packages/jest-validate/src/__tests__/fixtures/',
67-
'/packages/jest-worker/src/__performance_tests__',
68-
'/packages/pretty-format/perf/test.js',
6968
'/e2e/__tests__/iterator-to-null-test.ts',
7069
],
7170
testTimeout: 70000,

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
"test-types": "yarn jest --config jest.config.tsd.mjs",
107107
"test-ci-partial": "yarn test-ci-partial:parallel -i",
108108
"test-ci-partial:parallel": "yarn jest --color --config jest.config.ci.mjs",
109-
"test-pretty-format-perf": "node packages/pretty-format/perf/test.js",
110109
"test-leak": "yarn jest -i --detectLeaks --color jest-mock jest-diff jest-repl pretty-format",
111110
"test": "yarn lint && yarn jest",
112111
"verify-old-ts": "node ./scripts/verifyOldTs.mjs",

packages/diff-sequences/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**/__mocks__/**
22
**/__tests__/**
3+
__benchmarks__
34
__typetests__
45
src
56
tsconfig.json

packages/diff-sequences/perf/index.js renamed to packages/diff-sequences/__benchmarks__/test.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
// Make sure to run node with --expose-gc option!
9-
10-
// The times are reliable if about 1% relative mean error if you run it:
8+
/**
9+
* To start the test, build the repo and run:
10+
* node --expose-gc test.js
11+
*/
1112

12-
// * immediately after restart
13-
// * with 100% battery charge
14-
// * not connected to network
13+
/**
14+
* The times are reliable if about 1% relative mean error if you run it:
15+
* - immediately after restart
16+
* - with 100% battery charge
17+
* - not connected to network
18+
*/
1519

16-
/* eslint import/no-extraneous-dependencies: "off" */
20+
'use strict';
1721

1822
const Benchmark = require('benchmark');
1923
const diffBaseline = require('diff').diffLines;
20-
const diffImproved = require('../build/index.js').default;
24+
const diffImproved = require('../').default;
2125

2226
const testBaseline = (a, b) => {
2327
const benchmark = new Benchmark({
@@ -163,6 +167,10 @@ const testLength = n => {
163167
); // simulate TDD
164168
};
165169

170+
if (!globalThis.gc) {
171+
throw new Error('GC not present, start with: node --expose-gc test.js');
172+
}
173+
166174
writeHeading2();
167175

168176
testLength(20);

packages/diff-sequences/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
},
2828
"./package.json": "./package.json"
2929
},
30-
"scripts": {
31-
"perf": "node --expose-gc perf/index.js"
32-
},
3330
"devDependencies": {
3431
"benchmark": "^2.1.4",
3532
"diff": "^5.0.0",

packages/jest-worker/.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
**/__mocks__/**
22
**/__tests__/**
3-
**/__performance_tests__/**
3+
__benchmarks__
44
__typetests__
55
src
66
tsconfig.json

packages/jest-worker/src/__performance_tests__/test.js renamed to packages/jest-worker/__benchmarks__/test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
/**
9+
* To start the test, build the repo and run:
10+
* node --expose-gc test.js empty 100000
11+
* node --expose-gc test.js loadTest 10000
12+
*/
13+
814
'use strict';
915

1016
const assert = require('assert');
1117
const {performance} = require('perf_hooks');
12-
// eslint-disable-next-line import/no-extraneous-dependencies
1318
const workerFarm = require('worker-farm');
14-
const JestWorker = require('../../build').Worker;
19+
const JestWorker = require('../').Worker;
1520

16-
// Typical tests: node --expose-gc test.js empty 100000
17-
// node --expose-gc test.js loadTest 10000
1821
assert(process.argv[2], 'Pass a child method name');
1922
assert(process.argv[3], 'Pass the number of iterations');
2023

2124
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
2225
const method = process.argv[2];
23-
const calls = +process.argv[3];
26+
const calls = Number(process.argv[3]);
2427
const threads = 6;
2528
const iterations = 10;
2629

@@ -127,7 +130,7 @@ function profileEnd(x) {
127130

128131
async function main() {
129132
if (!globalThis.gc) {
130-
console.warn('GC not present, start with node --expose-gc');
133+
throw new Error('GC not present, start with node --expose-gc');
131134
}
132135

133136
const wFResults = [];

packages/jest-worker/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"outDir": "build"
66
},
77
"include": ["./src/**/*"],
8-
"exclude": ["./**/__performance_tests__/**/*", "./**/__tests__/**/*"],
8+
"exclude": ["./**/__tests__/**/*"],
99
"references": [{"path": "../jest-leak-detector"}]
1010
}

packages/pretty-format/.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
**/__mocks__/**
22
**/__tests__/**
3+
__benchmarks__
34
__typetests__
45
src
5-
perf
66
tsconfig.json
77
tsconfig.tsbuildinfo
88
api-extractor.json

packages/pretty-format/perf/test.js renamed to packages/pretty-format/__benchmarks__/test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
/**
9+
* To start the test, build the repo and run:
10+
* node test.js
11+
*/
12+
13+
'use strict';
14+
815
const util = require('util');
916
const chalk = require('chalk');
1017
const React = require('react');
1118
const ReactTestRenderer = require('react-test-renderer');
1219
const {formatTime} = require('jest-util');
13-
const prettyFormat = require('../build');
14-
const ReactTestComponent = require('../build/plugins/ReactTestComponent');
20+
const prettyFormat = require('../').format;
21+
const {ReactTestComponent} = require('../').plugins;
1522
const worldGeoJson = require('./world.geo.json');
1623

1724
const NANOSECONDS = 1000000000;

0 commit comments

Comments
 (0)