diff --git a/README.md b/README.md index 4bffac1..16c86d0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/benchmark/suite.js b/benchmark/suite.js index 284301d..751c6e1 100644 --- a/benchmark/suite.js +++ b/benchmark/suite.js @@ -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 }, @@ -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); });