Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): tweek micro-benchmarks to make them more consistent #33207

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/core/test/render3/perf/README.md
@@ -1,19 +1,19 @@
### Build

```
yarn bazel build //packages/core/test/render3/perf:{name}.min_debug.es2015.js --define=compile=aot
yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.es2015.js --define=compile=aot
```

### Run

```
node dist/bin/packages/core/test/render3/perf/{name}.min_debug.es2015.js
node dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js
```

### Profile

```
node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/{name}.min_debug.es2015.js
node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js
```

then connect with a debugger (the `--inspect-brk` option will make sure that benchmark execution doesn't start until a debugger is connected and the code execution is manually resumed).
Expand Down Expand Up @@ -64,7 +64,8 @@ The resulting output should look something like this:

### Notes

In all the above commands {name} should be replaced with the actual benchmark (folder) name, ex.:
In all the above commands `${BENCHMARK}` should be replaced with the actual benchmark (folder) name, ex.:
- build: `yarn bazel build //packages/core/test/render3/perf:noop_change_detection.min_debug.es2015.js --define=compile=aot`
- run: `time node dist/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.es2015.js`
- profile: `node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.es2015.js profile`
- experimenting `BENCHMARK=noop_change_detection; yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.es2015.js --define=compile=aot && node dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js`
Expand Up @@ -90,9 +90,7 @@ const createTime = directiveInstantiate('create');

console.profile('directive_instantiate');
while (createTime()) {
for (let i = 0; i < 50000; i++) {
createAndRenderLView(null, embeddedTView, viewTNode);
}
createAndRenderLView(null, embeddedTView, viewTNode);
}
console.profileEnd();

Expand Down
4 changes: 1 addition & 3 deletions packages/core/test/render3/perf/element_text_create/index.ts
Expand Up @@ -81,9 +81,7 @@ const createTime = elementTextCreate('create');

console.profile('element_text_create');
while (createTime()) {
for (let i = 0; i < 100000; i++) {
createAndRenderLView(null, embeddedTView, viewTNode);
}
createAndRenderLView(null, embeddedTView, viewTNode);
}
console.profileEnd();

Expand Down
7 changes: 5 additions & 2 deletions packages/core/test/render3/perf/micro_bench.ts
Expand Up @@ -7,8 +7,11 @@
*/
const performance = require('perf_hooks').performance;

const MIN_SAMPLE_COUNT_NO_IMPROVEMENT = 30;
const MIN_SAMPLE_DURATION = 100;
// Higher number here makes it more likely that we are more sure of the result.
const MIN_SAMPLE_COUNT_NO_IMPROVEMENT = 100;
// A smaller number here means that we are coming too close on timer resultion, but it also means
// that it is less likely that we will be bothered by GC or preemptive multi tasking.
const MIN_SAMPLE_DURATION = 10;

const UNITS = ['ms', 'us', 'ns', 'ps'];
export interface Benchmark {
Expand Down