Skip to content

Commit

Permalink
chore: cleanup benchmark scripts (jestjs#12688)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas authored Apr 19, 2022
1 parent aa3692d commit 7f484cb
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 33 deletions.
9 changes: 3 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ module.exports = {
},
{
files: [
'e2e/**',
'website/**',
'**/__benchmarks__/**',
'**/__tests__/**',
'e2e/**',
'**/pretty-format/perf/**',
'packages/jest-types/**/*',
'.eslintplugin/**',
],
Expand All @@ -263,6 +263,7 @@ module.exports = {
{
files: [
'scripts/*',
'packages/*/__benchmarks__/test.js',
'packages/jest-cli/src/init/index.ts',
'packages/jest-repl/src/cli/runtime-cli.ts',
],
Expand All @@ -274,14 +275,10 @@ module.exports = {
files: [
'e2e/**',
'examples/**',
'scripts/*',
'website/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__typetests__/**',
'**/__performance_tests__/**',
'packages/diff-sequences/perf/index.js',
'packages/pretty-format/perf/test.js',
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ coverage
/packages/*/build
/packages/*/dist
/packages/jest-config/src/__tests__/jest-preset.json
/packages/pretty-format/perf/world.geo.json
/packages/pretty-format/__benchmarks__/world.geo.json

# Breaks tests
/e2e/coverage-handlebars/greet.hbs
Expand Down
5 changes: 2 additions & 3 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
'**/packages/*/**/*.ts',
'!**/bin/**',
'!**/cli/**',
'!**/perf/**',
'!**/__benchmarks__/**',
'!**/__mocks__/**',
'!**/__tests__/**',
'!**/__typetests__/**',
Expand All @@ -38,6 +38,7 @@ export default {
snapshotSerializers: [require.resolve('pretty-format/ConvertAnsi')],
testPathIgnorePatterns: [
'/__arbitraries__/',
'/__benchmarks__/',
'/__typetests__/',
'/node_modules/',
'/examples/',
Expand All @@ -64,8 +65,6 @@ export default {
'/packages/jest-snapshot/src/__tests__/plugins',
'/packages/jest-snapshot/src/__tests__/fixtures/',
'/packages/jest-validate/src/__tests__/fixtures/',
'/packages/jest-worker/src/__performance_tests__',
'/packages/pretty-format/perf/test.js',
'/e2e/__tests__/iterator-to-null-test.ts',
],
testTimeout: 70000,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"test-types": "yarn jest --config jest.config.tsd.mjs",
"test-ci-partial": "yarn test-ci-partial:parallel -i",
"test-ci-partial:parallel": "yarn jest --color --config jest.config.ci.mjs",
"test-pretty-format-perf": "node packages/pretty-format/perf/test.js",
"test-leak": "yarn jest -i --detectLeaks --color jest-mock jest-diff jest-repl pretty-format",
"test": "yarn lint && yarn jest",
"verify-old-ts": "node ./scripts/verifyOldTs.mjs",
Expand Down
1 change: 1 addition & 0 deletions packages/diff-sequences/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/__mocks__/**
**/__tests__/**
__benchmarks__
__typetests__
src
tsconfig.json
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
* LICENSE file in the root directory of this source tree.
*/

// Make sure to run node with --expose-gc option!

// The times are reliable if about 1% relative mean error if you run it:
/**
* To start the test, build the repo and run:
* node --expose-gc test.js
*/

// * immediately after restart
// * with 100% battery charge
// * not connected to network
/**
* The times are reliable if about 1% relative mean error if you run it:
* - immediately after restart
* - with 100% battery charge
* - not connected to network
*/

/* eslint import/no-extraneous-dependencies: "off" */
'use strict';

const Benchmark = require('benchmark');
const diffBaseline = require('diff').diffLines;
const diffImproved = require('../build/index.js').default;
const diffImproved = require('../').default;

const testBaseline = (a, b) => {
const benchmark = new Benchmark({
Expand Down Expand Up @@ -163,6 +167,10 @@ const testLength = n => {
); // simulate TDD
};

if (!globalThis.gc) {
throw new Error('GC not present, start with: node --expose-gc test.js');
}

writeHeading2();

testLength(20);
Expand Down
3 changes: 0 additions & 3 deletions packages/diff-sequences/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
},
"./package.json": "./package.json"
},
"scripts": {
"perf": "node --expose-gc perf/index.js"
},
"devDependencies": {
"benchmark": "^2.1.4",
"diff": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/.npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/__mocks__/**
**/__tests__/**
**/__performance_tests__/**
__benchmarks__
__typetests__
src
tsconfig.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@
* LICENSE file in the root directory of this source tree.
*/

/**
* To start the test, build the repo and run:
* node --expose-gc test.js empty 100000
* node --expose-gc test.js loadTest 10000
*/

'use strict';

const assert = require('assert');
const {performance} = require('perf_hooks');
// eslint-disable-next-line import/no-extraneous-dependencies
const workerFarm = require('worker-farm');
const JestWorker = require('../../build').Worker;
const JestWorker = require('../').Worker;

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

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const method = process.argv[2];
const calls = +process.argv[3];
const calls = Number(process.argv[3]);
const threads = 6;
const iterations = 10;

Expand Down Expand Up @@ -127,7 +130,7 @@ function profileEnd(x) {

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

const wFResults = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"outDir": "build"
},
"include": ["./src/**/*"],
"exclude": ["./**/__performance_tests__/**/*", "./**/__tests__/**/*"],
"exclude": ["./**/__tests__/**/*"],
"references": [{"path": "../jest-leak-detector"}]
}
2 changes: 1 addition & 1 deletion packages/pretty-format/.npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**/__mocks__/**
**/__tests__/**
__benchmarks__
__typetests__
src
perf
tsconfig.json
tsconfig.tsbuildinfo
api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
* LICENSE file in the root directory of this source tree.
*/

/**
* To start the test, build the repo and run:
* node test.js
*/

'use strict';

const util = require('util');
const chalk = require('chalk');
const React = require('react');
const ReactTestRenderer = require('react-test-renderer');
const {formatTime} = require('jest-util');
const prettyFormat = require('../build');
const ReactTestComponent = require('../build/plugins/ReactTestComponent');
const prettyFormat = require('../').format;
const {ReactTestComponent} = require('../').plugins;
const worldGeoJson = require('./world.geo.json');

const NANOSECONDS = 1000000000;
Expand Down
File renamed without changes.

0 comments on commit 7f484cb

Please sign in to comment.