Skip to content

Commit 85e477c

Browse files
committed
test(perf): add per test file overhead benchmark
1 parent 570f088 commit 85e477c

File tree

8 files changed

+31
-0
lines changed

8 files changed

+31
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
/website/translated_docs
2828
/website/i18n/*
2929

30+
/benchmarks/*/node_modules/
31+
3032
/reports/*
3133

3234
coverage
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[1-9]*.test.js
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
it('is fast', () => {});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
First, run `./prepare.sh` to generate the benchmark files. On Windows, use a Bash (WSL, Git, Cygwinm ...) to do this, but you can use CMD for the actual benchmark run if the CMD environment is what you want to benchmark for.
2+
3+
To run the benchmark, use a benchmarking tool such as [hyperfine](https://github.com/sharkdp/hyperfine):
4+
```sh
5+
hyperfine -w 3 -m 10 ../../jest /tmp/other-jest-clone-to-compare-against/jest
6+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"jest": {
3+
"testEnvironment": "node"
4+
}
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
for i in {1..499}; do
3+
cp 0.test.js $i.test.js
4+
done
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 4
6+
7+
"root-workspace-0b6124@workspace:.":
8+
version: 0.0.0-use.local
9+
resolution: "root-workspace-0b6124@workspace:."
10+
languageName: unknown
11+
linkType: soft

packages/jest-runtime/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type ModuleRegistry = Map<string, InitialModule | Module>;
100100
// * take sufficiently long to require to warrant an optimization.
101101
// When required from the outside, they use the worker's require cache and are thus
102102
// only loaded once per worker, not once per test file.
103+
// Use /benchmarks/test-file-overhead to measure the impact.
103104
// Note that this only applies when they are required in an internal context;
104105
// users who require one of these modules in their tests will still get the module from inside the VM.
105106
// Prefer listing a module here only if it is impractical to use the jest-resolve-outside-vm-option where it is required,

0 commit comments

Comments
 (0)