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

Adds version as argument to benchmark script #336

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,24 @@ npm run update-rules
npm run build
```

Feel free to fork if you see possible improvements!
## Benchmarking

Compare ops/sec using local source vs _latest_ published version.

```sh
npm run benchmark
```

Compare to a specific version:

```sh
npm run benchmark -- v1.13.0
```

CAVEATS:

* The benchmarking script only works on ESM (it uses [`vm.SourceTextModule`](https://nodejs.org/docs/latest-v20.x/api/vm.html#class-vmsourcetextmodule)),
so we can only compare to `v1.13.0` and above.

## Acknowledgements

Expand Down
6 changes: 2 additions & 4 deletions benchmark/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ const fetchModule = async (version) => {
return mod.namespace;
};

const main = async () => {
const compareToVersion = 'v1.13.0';

const main = async (compareToVersion = 'latest') => {
const results = await runSuites([
{ module: psl, version: 'source' },
{ module: await fetchModule(compareToVersion), version: compareToVersion },
Expand All @@ -120,7 +118,7 @@ const main = async () => {
printResults(results, compareToVersion);
};

main().catch((error) => {
main(process.argv[2]).catch((error) => {
console.error(error);
process.exit(1);
});