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

benchmark: create benchmark for typescript #54904

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marco-ippolito
Copy link
Member

Some benchmarks for --experimental-strip-types and --experimental-transform-types.
First time writing a benchmark so open to suggestions

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Sep 12, 2024
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/transform-types.js Outdated Show resolved Hide resolved
@RedYetiDev
Copy link
Member

IIRC, dead-code elimination may affect the becnhmark, so setting a variable, and later asserting it will prevent that.

@RedYetiDev RedYetiDev added the strip-types Issues or PRs related to strip-types support label Sep 12, 2024
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
@RafaelGSS
Copy link
Member

IIRC, dead-code elimination may affect the becnhmark, so setting a variable, and later asserting it will prevent that.

There's no guarantee on that. It's just an assumption that might not be true. However, it's recommended to do it.

@marco-ippolito marco-ippolito force-pushed the benchmark/bench-strip-transform-types branch 2 times, most recently from bdfb933 to b8e57a3 Compare September 12, 2024 13:44
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/strip-types.js Outdated Show resolved Hide resolved
benchmark/ts/transform-types.js Outdated Show resolved Hide resolved
@marco-ippolito marco-ippolito force-pushed the benchmark/bench-strip-transform-types branch 2 times, most recently from 3c71807 to 3489ce0 Compare September 12, 2024 13:57
@marco-ippolito marco-ippolito force-pushed the benchmark/bench-strip-transform-types branch from 3489ce0 to 5bafadd Compare September 12, 2024 14:02
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only way to measure this is by spawning a new process or possibly a worker thread.

let output;
bench.start();
for (let i = 0; i < n; i++) {
const { result } = await import(filepath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will just hit the module cache.

Copy link
Member

@RedYetiDev RedYetiDev Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about <filepath>?${i}? (I don't know too much about the module cache)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Issues and PRs related to the benchmark subsystem. strip-types Issues or PRs related to strip-types support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants