Skip to content

chore: switch performance tests to hyperfine #19919

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

Merged
merged 4 commits into from
Jul 17, 2025
Merged

chore: switch performance tests to hyperfine #19919

merged 4 commits into from
Jul 17, 2025

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Jul 6, 2025

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[X] Other, please explain:

Update performance tests

Fixes #19680

What changes did you make? (Give an overview)

Updated performance tests to use hyperfine.

  • The time for the "Loading" benchmark now includes the time to setup the Node.js process that requires ./lib/api.js. This is why it reports larger values than the previously.
  • I've adding a warmup run before each benchmark to get less biased results. This makes each benchmark ~20% slower.

Example output of npm run test:performance:

image

Is there anything you'd like reviewers to focus on?

I haven't changed the benchmark commands themselves, so for example the "Single File" test still measures the time to lint tests/performance/jshint.js with all built-in rules turned on; "Multi Files" downloads and lints ESLint v1.10.3. For this reason it should be possible to directly compare the new hyperfine-generated results with the results generated by the current implementation, at least for these two tests. Ideally, hyperfine should generate less variable, hence more consistent results across runs.

@eslint-github-bot eslint-github-bot bot added the chore This change is not user-facing label Jul 6, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 6, 2025
Copy link

netlify bot commented Jul 6, 2025

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit c50f3a6
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/6878c062f6441a000899f243

@fasttime fasttime marked this pull request as ready for review July 8, 2025 11:12
@fasttime fasttime requested a review from a team as a code owner July 8, 2025 11:12
nzakas
nzakas previously approved these changes Jul 10, 2025
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Tested locally and works like a charm. Would like @mdjermanovic to review before merging.

@nzakas nzakas moved this from Needs Triage to Second Review Needed in Triage Jul 10, 2025
Makefile.js Outdated

results.sort((a, b) => a - b);
const median = results[~~(results.length / 2)];
const loadingCommand = `"${process.execPath}" --require "${require("./package.json").main}" ""`;
Copy link
Member

Choose a reason for hiding this comment

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

Question for better understanding: what is the expected purpose of the "" at the end of the command? When I run the command ("C:\Program Files\nodejs\node.exe" --require "./lib/api.js" "") directly, Node.js prompts for input. Perhaps it was intended to be --eval ""? Though, I don't see any difference between "" present, "" omitted, and --eval "" when running npm run test:performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, it seems that "" is actually unnecessary. When I run node --require "./lib/api.js" "" I also see Node.js running in REPL mode and prompting for input. I imagine that hyperfine is suppressing stdin and so the command behaves like echo "" | node --require "./lib/api.js" "", and that explains the different behavior. If this difference is surprising we could instead add --eval=0 or alternatively just do `"${process.execPath}" "${require("./package.json").main}"`, to require ./lib/api.js as an entry point.

Copy link
Member

Choose a reason for hiding this comment

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

just do `"${process.execPath}" "${require("./package.json").main}"`, to require ./lib/api.js as an entry point.

This looks good to me 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Updated in c50f3a6.

@mdjermanovic
Copy link
Member

I haven't changed the benchmark commands themselves, so for example the "Single File" test still measures the time to lint tests/performance/jshint.js with all built-in rules turned on; "Multi Files" downloads and lints ESLint v1.10.3. For this reason it should be possible to directly compare the new hyperfine-generated results with the results generated by the current implementation, at least for these two tests.

I'm getting very similar results as with the old (current) "Single File" and "Multi Files" performance tests implementation. But, unlike with the old implementation, results with the new implementation seem to be very consistent 👍

@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jul 15, 2025
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit e855717 into main Jul 17, 2025
30 checks passed
@mdjermanovic mdjermanovic deleted the hyperfine branch July 17, 2025 10:19
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion chore This change is not user-facing
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Change Request: Repeatable performance test
4 participants