From 4fd59a491ca6418892e8781c001957e4f7463e22 Mon Sep 17 00:00:00 2001 From: Lupo Montero Date: Thu, 28 Nov 2024 19:48:18 +0100 Subject: [PATCH 1/2] feat(benchmark): Adds version argument to benchmark script #335 --- benchmark/suite.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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); }); From a8203ff7927816c1a08c7c5f210ee572abb5e54d Mon Sep 17 00:00:00 2001 From: Lupo Montero Date: Thu, 28 Nov 2024 19:48:49 +0100 Subject: [PATCH 2/2] doc(benchmark): Adds benchmarking info to readme --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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